From 817c1df9516bc946980b400ffd8bcf027222b39d Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Feb 17 2011 17:31:33 +0000 Subject: Update shell functionality. --- diff --git a/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed b/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed index 5bd9c87..e8e5e2c 100644 --- a/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed +++ b/Scripts/Bash/Functions/Shell/Config/tpl_forCopyright.sed @@ -6,7 +6,7 @@ # $Id$ # --------------------------------------------------- /^# +Copyright .*$/a\ -# Copyright (C) =YEAR1=-=YEAR2= =FULLNAME=\ +# Copyright (C) =COPYRIGHT_YEAR== =COPYRIGHT_HOLDER=\ # \ # This program is free software; you can redistribute it and/or\ # modify it under the terms of the GNU General Public License as\ diff --git a/Scripts/Bash/Functions/Shell/shell.sh b/Scripts/Bash/Functions/Shell/shell.sh index 3771800..f7d573d 100755 --- a/Scripts/Bash/Functions/Shell/shell.sh +++ b/Scripts/Bash/Functions/Shell/shell.sh @@ -26,9 +26,6 @@ function shell { - # Define variables. - local FILES='' - # Define command-line interface. shell_getActions diff --git a/Scripts/Bash/Functions/Shell/shell_getActions.sh b/Scripts/Bash/Functions/Shell/shell_getActions.sh index 3af39b8..c55606f 100755 --- a/Scripts/Bash/Functions/Shell/shell_getActions.sh +++ b/Scripts/Bash/Functions/Shell/shell_getActions.sh @@ -30,7 +30,7 @@ function shell_getActions { local ARGSS="" # Define long options we want to support. - local ARGSL="filter:,update-copyright:" + local ARGSL="update-copyright:" # Parse arguments using getopt(1) command parser. cli_doParseArguments @@ -49,32 +49,11 @@ function shell_getActions { # Define action value. ACTIONVAL="$2" - # Check action value. Be sure the action value matches - # the convenctions defined for source locations inside - # the working copy. - cli_checkRepoDirSource - # Define action name using action value as reference. ACTIONNAM="${FUNCNAM}_updateCopyright" - # Look for sub-options passed through command-line. - while true; do - case "$3" in - --filter ) - # Redefine regular expression. - FLAG_FILTER="$4" - # Rotate positional parameters - shift 4 - ;; - * ) - # Break sub-options loop. - break - ;; - esac - done - - # Break options loop. - break + # Rotate positional parameters. + shift 2 ;; * ) @@ -83,20 +62,25 @@ function shell_getActions { esac done - # Verify action value variable. - if [[ $ACTIONVAL == '' ]];then - cli_printMessage "$(caller)" 'AsToKnowMoreLine' - fi + # Check action value. Be sure the action value matches the + # convenctions defined for source locations inside the working + # copy. + cli_checkRepoDirSource - # Re-define regular expression to match shell files only. - FLAG_FILTER=$(echo "${FLAG_FILTER}.*\.(bash|shell|sh)") + # Syncronize changes between the working copy and the central + # repository to bring down changes. + cli_commitRepoChanges # Execute action name. if [[ $ACTIONNAM =~ "^${FUNCNAM}_[A-Za-z]+$" ]];then eval $ACTIONNAM else - cli_printMessage "`eval_gettext "A valid action is required."`" 'AsErrorLine' + cli_printMessage "`gettext "A valid action is required."`" 'AsErrorLine' cli_printMessage "$(caller)" 'AsToKnowMoreLine' fi + # Syncronize changes between the working copy and the central + # repository to commit up changes. + cli_commitRepoChanges + } diff --git a/Scripts/Bash/Functions/Shell/shell_updateCopyright.sh b/Scripts/Bash/Functions/Shell/shell_updateCopyright.sh index 46b631b..bbfeb1b 100755 --- a/Scripts/Bash/Functions/Shell/shell_updateCopyright.sh +++ b/Scripts/Bash/Functions/Shell/shell_updateCopyright.sh @@ -28,9 +28,11 @@ function shell_updateCopyright { - local TEMPLATES='' - local INSTANCE='' + local FILE='' local COUNT=0 + local FILES='' + local INSTANCE='' + local TEMPLATES='' local -a TITLE local -a VALUE local -a PATTERN @@ -48,35 +50,30 @@ function shell_updateCopyright { INSTANCE=$(cli_getTemporalFile $TEMPLATE) # Define copyright information. - TITLE[0]="`gettext "Your full name"`" - TITLE[1]="`gettext "Year which you started working in"`" - TITLE[2]="`gettext "Year which you stopped working in"`" + TITLE[0]="`gettext "Copyright holder"`" + TITLE[1]="`gettext "Copyright year"`" # Define translation marker. These values are used inside # template file. - MARKER[0]='=FULLNAME=' - MARKER[1]='=YEAR1=' - MARKER[2]='=YEAR2=' + MARKER[0]='=COPYRIGHT_HOLDER=' + MARKER[1]='=COPYRIGHT_YEAR=' # Define pattern. These values are used as regular # expression patterns for user's input further verification. PATTERN[0]='^([[:alnum:] _-.]+)?$' PATTERN[1]='^([[:digit:]]{4})?$' - PATTERN[2]=${PATTERN[1]} # Define pattern message. These values are used as output # message when user's input doesn't match the related pattern. PATTERN_MSG[0]="`gettext "Try using alphanumeric characters."`" PATTERN_MSG[1]="`gettext "Try using numeric characters."`" - PATTERN_MSG[2]=${PATTERN_MSG[1]} # Define default values. - DEFAULT[0]="The CentOS Project" - DEFAULT[1]='2003' - DEFAULT[2]=$(date +%Y) + DEFAULT[0]="The CentOS Project. `gettext "All rights reserved."`" + DEFAULT[1]=$(date +%Y) # Initialize values using user's input. - cli_printMessage "`gettext "Enter copyright information you want to apply:"`" + cli_printMessage "`gettext "Enter the information you want to apply:"`" while [[ $COUNT -ne ${#TITLE[*]} ]];do # Request value. @@ -121,9 +118,19 @@ function shell_updateCopyright { done - # Define list of files to process. + # Redefine filter flag to specify the extension of shell scripts + # we want to update copyright information on. Use action value as + # reference to find out different shell files. + FLAG_FILTER=".*${FLAG_FILTER}.*\.sh" + + # Define list of shell scripts to be processed. cli_getFilesList + # Print out action preamble. Since the `--filter' option can be + # supplied, it is useful to know which files we are getting + # translatable strings from. + cli_printActionPreamble "${FILES}" "doLocale" 'AsResponseLine' + # Process list of files. for FILE in $FILES;do @@ -133,15 +140,11 @@ function shell_updateCopyright { # Apply template instance to file. sed -r -i -f $INSTANCE $FILE - done \ - | awk -f /home/centos/artwork/trunk/Scripts/Bash/Styles/output_forTwoColumns.awk + done # Remove template instance. - cli_checkFiles "${INSTANCE}" 'f' - rm $INSTANCE - - # Check repository changes and ask you to commit them up to - # central repository. - cli_commitRepoChanges + if [[ -f ${INSTANCE} ]];then + rm ${INSTANCE} + fi }