From 5ea0816649185ff3321cfd79f8dfcc8c4f48adac Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 03 2011 01:52:21 +0000 Subject: Update cli_printMessage.sh: - Unify `--as-creating-line' and `--as-updating-line' options into the same option. From now on, desition on whether to `update' or `create' a file is taken from file verification not the option you specify. When the file exist we update it and when the file doesn't exist we create it. - In order to achive the file vefication successfully, it was necessary to move the action of path reduction we did through sed before the MESSAGE variable be evaluated. This transformation is now part of the default printing format. - All leading spaces are removed before evaluating the MESSAGE variable. - In order for file verification to work, the option `--as-creating-line' and `--as-updating-line' must contain one absolute path as value only. --- diff --git a/Scripts/Functions/cli_printMessage.sh b/Scripts/Functions/cli_printMessage.sh index c8026a0..fe5ba0b 100755 --- a/Scripts/Functions/cli_printMessage.sh +++ b/Scripts/Functions/cli_printMessage.sh @@ -46,11 +46,8 @@ function cli_printMessage { # printed out on the screen. MESSAGE=$(echo $MESSAGE | sed -e "s/\\\0x27/'/g") - # Reduce paths and leading spaces from output messages. The main - # purpose for this is to free horizontal space on output messages. - MESSAGE=$(echo "$MESSAGE" | sed -r \ - -e "s!${HOME}/artwork/(trunk|branches|tags)/!\1/!g" \ - -e 's!^[[:space:]]+!!') + # Remove empty spaces from message. + MESSAGE=$(echo $MESSAGE | sed -e 's!^[[:space:]]+!!') # Print out messages based on format. case "$FORMAT" in @@ -77,10 +74,6 @@ function cli_printMessage { cli_printMessage '-' --as-separator-line ;; - --as-updating-line ) - cli_printMessage "`gettext "Updating"`: $MESSAGE" - ;; - --as-cropping-line ) cli_printMessage "`gettext "Cropping from"`: $MESSAGE" ;; @@ -93,8 +86,12 @@ function cli_printMessage { cli_printMessage "`gettext "Checking"`: $MESSAGE" ;; - --as-creating-line ) - cli_printMessage "`gettext "Creating"`: $MESSAGE" + --as-creating-line | --as-updating-line ) + if [[ -a "$MESSAGE" ]];then + cli_printMessage "`gettext "Updating"`: $MESSAGE" + else + cli_printMessage "`gettext "Creating"`: $MESSAGE" + fi ;; --as-deleting-line ) @@ -212,7 +209,14 @@ function cli_printMessage { ;; * ) - echo "$MESSAGE" \ + + # Default printing format. This is the format used when no + # other specification is passed to this function. As + # convenience, we transform absolute paths into relative + # paths in order to free horizontal space on final output + # messages. + echo "$MESSAGE" | sed -r \ + -e "s!${HOME}/artwork/(trunk|branches|tags)/!\1/!g" \ | awk 'BEGIN { FS=": " } { if ( $0 ~ /^-+$/ )