| #!/bin/bash |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| function cli_checkFiles { |
| |
| |
| local ARGSS='d,r,h,x,w' |
| |
| |
| local ARGSL='directory,regular-file,symbolic-link,execution,working-copy' |
| |
| |
| |
| local ARGUMENTS='' |
| |
| |
| |
| |
| local FILE='' |
| |
| |
| cli_doParseArgumentsReDef "$@" |
| |
| |
| cli_doParseArguments |
| |
| |
| eval set -- "$ARGUMENTS" |
| |
| |
| local FILES=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') |
| |
| |
| if [[ $FILES == '--' ]];then |
| cli_printMessage "You need to provide one file at least." --as-error-line |
| fi |
| |
| |
| while true; do |
| |
| case "$1" in |
| |
| -d|--directory ) |
| for FILE in $(echo $FILES);do |
| if [[ ! -d $FILE ]];then |
| cli_printMessage "`eval_gettext "The directory \\\"\\\$FILE\\\" does not exist."`" --as-error-line |
| fi |
| done |
| shift 1 |
| ;; |
| |
| -f|--regular-file ) |
| for FILE in $(echo $FILES);do |
| if [[ ! -f $FILE ]];then |
| cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not a regular file."`" --as-error-line |
| fi |
| done |
| shift 1 |
| ;; |
| |
| -h|--symbolic-link ) |
| for FILE in $(echo $FILES);do |
| if [[ ! -h $FILE ]];then |
| cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not a symbolic link."`" --as-error-line |
| fi |
| done |
| shift 1 |
| ;; |
| |
| -x|--execution ) |
| for FILE in $(echo $FILES);do |
| if [[ ! -x $FILE ]];then |
| cli_printMessage "`eval_gettext "The file \\\"\\\$FILE\\\" is not executable."`" --as-error-line |
| fi |
| done |
| shift 1 |
| ;; |
| |
| -w|--working-copy ) |
| for FILE in $(echo $FILES);do |
| if [[ ! $FILE =~ "^${HOME}/artwork/.+$" ]];then |
| cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" does not exist inside the working copy."`" --as-error-line |
| fi |
| done |
| shift 1 |
| ;; |
| |
| -- ) |
| for FILE in $(echo $FILES);do |
| if [[ ! -a $FILE ]];then |
| cli_printMessage "`eval_gettext "The path \\\"\\\$FILE\\\" does not exist."`" --as-error-line |
| fi |
| done |
| shift 1 |
| break |
| ;; |
| |
| esac |
| done |
| |
| } |
| |