From d1225f3ec4d8c89bec9e697df6a6756b2ea65392 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 23 2011 17:16:58 +0000 Subject: Update cli_getFilesList.sh and cli_printActionPreamble.sh: - The verification of FILES was moved from cli_getFilesList.sh to cli_printActionPreamble, again. I thought that if make cli_printMessage output to standard error (/dev/stderr) there would be no problem with assigning the output of cli_getFilesList to a variable. If some error exist it would not be stored inside the variable because assignment is done from standard output no standard error. I tested this in the shell prompt and seems to work that way there, but not inside centos-art.sh. I am missing something surely. Anyway, put FILES verifications (that includes whatever kind of output) inside cli_printActionPreamble. --- diff --git a/Scripts/Bash/Functions/cli_getFilesList.sh b/Scripts/Bash/Functions/cli_getFilesList.sh index 1d76f03..679cec5 100755 --- a/Scripts/Bash/Functions/cli_getFilesList.sh +++ b/Scripts/Bash/Functions/cli_getFilesList.sh @@ -66,14 +66,7 @@ function cli_getFilesList { FILES=$LOCATION fi - # Check list of files to process. If we have an empty list of - # files, inform about it and stop script execution. Otherwise - # print list of files. - if [[ "$FILES" == '' ]];then - cli_printMessage "`gettext "There is no file to process."`" 'AsErrorLine' - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - else - echo "$FILES" - fi + # Output list of files to process. + echo "$FILES" } diff --git a/Scripts/Bash/Functions/cli_printActionPreamble.sh b/Scripts/Bash/Functions/cli_printActionPreamble.sh index 8360cfa..aade07a 100755 --- a/Scripts/Bash/Functions/cli_printActionPreamble.sh +++ b/Scripts/Bash/Functions/cli_printActionPreamble.sh @@ -38,6 +38,20 @@ function cli_printActionPreamble { local ACTION="$2" local FORMAT="$3" + # Check list of files to process. If we have an empty list of + # files, inform about it and stop script execution. Otherwise + # print list of files. + if [[ "$FILES" == '' ]];then + cli_printMessage "`gettext "There is no file to process."`" 'AsErrorLine' + cli_printMessage "$(caller)" 'AsToKnowMoreLine' + fi + + # Verify that all function parameters are passed. If they are not, + # there is nothing else to do here. + if [[ $# -ne 3 ]];then + return + fi + # Redefine total number of directories. COUNT=$(echo "$FILES" | sed -r "s! +!\n!g" | wc -l)