From 6253fcb7b0a1d014a2586f247509dff2892764a7 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Oct 14 2010 03:05:24 +0000 Subject: Update cli_checkFiles.sh function: - Add fourth argument evaluation. This is mainly used for the need of evaluate files and directories silently without print any message in order to use the retrun value as reference for further evaluation. For example, we can do the following: cli_checkFiles $FILE 'f' '' '--quiet' if [[ $? -eq 0 ]];then # File does exist, do something accordingly. else # File does not exist, do something accordingly. fi to evaluate files and directories without printing the action message. To print the action message just remove the '--quiet' option from function invokation argument list. Update cli_printMessage.sh function: - Start using output_forRendering.awk as based pattern to output messages. --- diff --git a/Scripts/Bash/Functions/cli_checkFiles.sh b/Scripts/Bash/Functions/cli_checkFiles.sh index 1cdb4ac..1873e98 100644 --- a/Scripts/Bash/Functions/cli_checkFiles.sh +++ b/Scripts/Bash/Functions/cli_checkFiles.sh @@ -4,10 +4,10 @@ # # Copyright (C) 2009-2010 Alain Reguera Delgado # -# This program is free software; you can redistribute it and/or -# modify it under the terms of the GNU General Public License as -# published by the Free Software Foundation; either version 2 of the -# License, or (at your option) any later version. +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of @@ -29,6 +29,7 @@ function cli_checkFiles { local FILE="$1" local TYPE="$2" local ACTION="$3" + local OPTIONS="$4" local MESSAGE='' # Check amount of paramaters passed. At least one argument should @@ -46,7 +47,7 @@ function cli_checkFiles { # Check file provided. if [[ $FILE == '' ]];then MESSAGE="`gettext "Unknown"`" - cli_printMessage "${ACTION}: $MESSAGE" + cli_printMessage "${ACTION}: $MESSAGE" "AsRegularLine" return 1 fi @@ -91,13 +92,26 @@ function cli_checkFiles { esac - # If there is some message print it. - if [[ "$MESSAGE" == '' ]];then - cli_printMessage "${ACTION}: $FILE" - return 0 - else - cli_printMessage "${ACTION}: $MESSAGE" - return 1 - fi + # If there is some message print it when there is no `--quiet' + # option passed as fourth argument. + if [[ "$MESSAGE" == '' ]];then + for OPTION in $OPTIONS;do + case $OPTION in + '--quiet' ) + return 0 + esac + done + cli_printMessage "${ACTION}: $FILE" "AsRegularLine" + return 0 + else + for OPTION in $OPTIONS;do + case $OPTION in + '--quiet' ) + return 1 + esac + done + cli_printMessage "${ACTION}: $MESSAGE" "AsRegularLine" + return 1 + fi } diff --git a/Scripts/Bash/Functions/cli_printMessage.sh b/Scripts/Bash/Functions/cli_printMessage.sh index ab2d850..0aff79a 100755 --- a/Scripts/Bash/Functions/cli_printMessage.sh +++ b/Scripts/Bash/Functions/cli_printMessage.sh @@ -73,31 +73,43 @@ function cli_printMessage { ;; 'AsUpdatingLine' ) - echo "`gettext "Updating"`: $MESSAGE" + echo "`gettext "Updating"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsRemovingLine' ) - echo "`gettext "Removing"`: $MESSAGE" + echo "`gettext "Removing"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsCheckingLine' ) - echo "`gettext "Checking"`: $MESSAGE" + echo "`gettext "Checking"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsCreatingLine' ) - echo "`gettext "Creating"`: $MESSAGE" + echo "`gettext "Creating"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsSavedAsLine' ) - echo "`gettext "Saved as"`: $MESSAGE" + echo "`gettext "Saved as"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsLinkToLine' ) - echo "`gettext "Linked to"`: $MESSAGE" + echo "`gettext "Linked to"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk + ;; + + 'AsMovedToLine' ) + echo "`gettext "Moved to"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsTranslationLine' ) - echo "`gettext "Translation"`: $MESSAGE" + echo "`gettext "Translation"`: $MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; 'AsResponseLine' ) @@ -125,10 +137,17 @@ function cli_printMessage { MESSAGE=$(echo $MESSAGE | cut -d ' ' -f2-) MESSAGE="$(dirname $MESSAGE)' --filter='$(basename $MESSAGE)" echo "`gettext "To know more, run"`: centos-art help --read='$MESSAGE'" - exit + exit # <-- ATTENTION: Do not remove this line. We use this + # case as convenction to end script + # execution. + ;; + + 'AsRegularLine' ) + echo "$MESSAGE" \ + | awk -f /home/centos/artwork/trunk/Scripts/Bash/Functions/Render/Styles/output_forRendering.awk ;; - 'AsRegularLine' | * ) + * ) echo "$MESSAGE" ;;