From 615395d8a4e10415e49262153ca071f86f5971d0 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jul 08 2013 20:49:08 +0000 Subject: Update command-line interface of centos-art.sh script. - Previous to this commit, global configuration variables (like the one used to specify the repository's working copy) were set inside the centos-art.sh script, so to update their values it was required to update the centos-art.sh script. In this commit, all configuration variables were moved from centos-art.sh script to centos-art.conf file. This movement required to update centos-art.sh script to load the centos-art.conf file. - Previous to this commit, per-user configuration took place inside the user's ~/.bash_profile file. In this commit, per-user configuration takes place inside ~/.centos-art.conf file. Possible values to customize here include TCAR_USER_EDITOR and TCAR_USER_WRKDIR. Other variables might be added in the future. - Previous to this commit, I didn't put my name in any .sh file. In this commit, update the top comment adding my name, e-mail, and gpg fingerprint before the copyright information which I'm giving to The CentOS Project as long as this code be released under GPL terms. The e-mail information I publish in the scripts is local to my workstation where I've installed and configured a mail server for my friends to exchange information with me through the telephone line and a wifi access point -Internet access isn't available for most people in Cuba yet, so I feel motivated to provide alternative ways of accessing the services I've installed and configured in my own (CentOS) workstation. The $Id$ string was removed from top comment. - Previous to this commit, variable and function naming conventions were not very well established. In this commit, start using the following naming conventions: * All variable's name definitions that have a global scope to centos-art.sh script must begin with TCAR_. These variables are generally defined in centos-art.conf file. * All variable's name definitions that have a function-specific scope to centos-art.sh script must begin with FNAME_. Where FNAME is the name of the function the variable was defined for first time. In case of nested function-specific environments, the same model applies, using the deepest function name as reference. * All function's name definitions must begin with fname_. Where fname is the name of the function. Nested function definitions follow the same model using the last function name as reference. In this configuration, two nested function definitions at the same level cannot have the same name, so you need to be sure they are named differently. - Add function cli_printCaller to standardize the way caller information is retrieved. You can now make use of --name, --path and --line options to print caller information in whatever order you wish. - Previous to this commit, error messages triggered from cli_printMessage function were redirected to standard output. In this commit they are redirected to standard error output. This includes output from options --as-error-line, --as-toknowmore-line, --as-response-line, --as-notrailingnew-line and --as-stderr-line. - Previous to this commit, we were using cli_parseArguments and cli_parseArgumentsReDef to process command-line arguments through getopt command. In this commit, these to functions were integrated into cli_setArguments function. Both cli_parseArguments and cli_parseArgumentsReDef functions were removed. When parsing options, the cli_setArguments function defines the name convention used by local variables inside different function environments. See the top comment on cli_setArguments.sh file for more information about the variable names you should use. - All variables were enclosed in brackets. --- diff --git a/Automation/centos-art.conf b/Automation/centos-art.conf index b50c60f..5ab6514 100755 --- a/Automation/centos-art.conf +++ b/Automation/centos-art.conf @@ -1,20 +1,101 @@ +#!/bin/bash +######################################################################## # -# Welcome to centos-art configuration file. Here you can customize the -# way centos-art.sh script behaves inside The CentOS Artwork -# Repository. +# centos-art.conf -- This file provides default configuration values +# to centos-art.sh script. # +# Written by: +# * Alain Reguera Delgado , 2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2013 The CentOS Project +# +# 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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +######################################################################## -[repository] - -[identity] - -[documentation] - -[scripts] - -[locales] +# ---------------------------------------------------------------------- +# Command-line interface (read-only) configuration variables. +# ---------------------------------------------------------------------- +declare -xr TCAR_CLI_NAME="centos-art.sh" +declare -xr TCAR_CLI_COMMAND="centos-art" +declare -xr TCAR_CLI_VERSION='0.5' +declare -xr TCAR_CLI_LANG_LC=$(echo ${LANG} | cut -d'.' -f1) +declare -xr TCAR_CLI_LANG_LL=$(echo ${TCAR_CLI_LANG_LC} | cut -d'_' -f1) +declare -xr TCAR_CLI_LANG_CC=$(echo ${TCAR_CLI_LANG_LC} | cut -d'_' -f2) +declare -xr TCAR_CLI_BASEDIR=$(dirname ${0}) +declare -xr TCAR_CLI_MODSDIR=${TCAR_CLI_BASEDIR}/${TCAR_CLI_NAME}-mods +declare -xr TCAR_CLI_INIT_DIR=${TCAR_CLI_MODSDIR}/Cli +declare -xr TCAR_CLI_INIT_FILE=${TCAR_CLI_INIT_DIR}/cli.sh +declare -xr TCAR_CLI_INIT_FUNCTION=$(basename ${TCAR_CLI_INIT_FILE} | sed -r 's/\.sh$//') +declare -xr TCAR_CLI_L10NDIR=${TCAR_CLI_BASEDIR}/${TCAR_CLI_NAME}-l10n +declare -xr TCAR_CLI_TEMPDIR=$(mktemp -p /tmp -d ${TCAR_CLI_NAME}-XXXXXX) -[version_control] +# ---------------------------------------------------------------------- +# User-related configuration variables. +# ---------------------------------------------------------------------- +# +# Set directory path to the working directory, inside your +# workstation. The working directory (a.k.a., working copy) is a +# directory holding the .git (or .svn) directory. It is the place +# where you stored the content of `git clone ...' (or `svn checkout +# ...') command. It is the directory where you make local changes and +# then send them up to a central repository. +# +declare -x TCAR_USER_WRKDIR=$(dirname ${TCAR_CLI_BASEDIR}) +# +# Set file path to your preferred text editor. The editor you specify +# will be use when you need to write commit messages and anything that +# requires text edition. +# +declare -x TCAR_USER_EDITOR=/bin/vi +# +# Set user-specific configuration file used by centos-art.sh script to +# determine where to retrieve user-specific configuration values. +# User-specific configuration files let you customize the way +# centos-art.sh behaves in a multi-user environment. This variable +# must be read-only. +# +declare -xr TCAR_USER_CONFIG=${HOME}/.centos-art.conf -package = "git" -enabled = "1" +# ---------------------------------------------------------------------- +# Flag-related configuration variables. +# ---------------------------------------------------------------------- +# +# Set filter flag (-f|--filter). This flag is mainly used to reduce +# the number of files to process and is interpreted as egrep-posix +# regular expression. By default, when this flag is not provided, all +# paths in the working copy will match, except files inside hidden +# directories like `.svn' and `.git' that will be omitted. +# +declare -x TCAR_FLAG_FILTER='[[:alnum:]_/-]+' +# +# Set verbosity flag (-q|--quiet). This flag controls whether +# centos-art.sh script prints messages or not. By default, all +# messages are suppressed except those directed to standard error. +# +declare -x TCAR_FLAG_QUIET='false' +# +# Set affirmative flag (-y|--yes). This flag controls whether +# centos-art.sh script does or does not pass confirmation request +# points. By default, it doesn't. +# +declare -x TCAR_FLAG_YES='false' +# +# Set synchronization flag (-z|--synchronize). This flag controls +# whether version control system is triggered or not after realizing +# changes to source files under version control. +# +declare -x TCAR_FLAG_SYNCHRONIZE='false' diff --git a/Automation/centos-art.sh b/Automation/centos-art.sh index 483e384..571791b 100755 --- a/Automation/centos-art.sh +++ b/Automation/centos-art.sh @@ -1,6 +1,11 @@ #!/bin/bash +######################################################################## # -# centos-art.sh -- The CentOS Artwork Repository automation tool. +# centos-art.sh -- The CentOS Artwork Repository automation tool. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -18,78 +23,25 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -# Initialize relative path (from repository first directory level on) -# used to store bash scripts. -TCAR_BASHSCRIPTS='Scripts/Bash' - -# Verify the working copy absolute path using the command path. It is -# not possible to consider relative paths here because we are using a -# symbolic link to create the connection between the centos-art.sh -# script and the centos-art command. The link location is stored -# inside ~/bin directory which is outside the repository directory -# structure. So we cannot use the command path as reference to define -# the repository working directory each time we run the command. -# Instead, in order to get the correct working directory path, it is -# required to finish the script execution when the absolute path -# points to the ~/bin directory and print an error message explaining -# the issue. This message cannot be translated to other languages -# because the TEXTDOMAINDIR variable hasn't been defined yet (it -# requires the working copy directory path to be defined first). -if [[ ! $TCAR_WORKDIR ]] || [[ $TCAR_WORKDIR == '' ]] ;then - - if [[ $0 =~ "^${HOME}/bin" ]];then - echo "To run centos-art correctly, you need to prepare your workstation first." - exit 1 - fi - -fi +######################################################################## -# Initialize absolute path to the working copy. Take care that, in -# some cases, you might execute centos-art.sh script from a path -# different to that set in TCAR_WORKDIR variable inside your -# ~/.bash_profile (e.g., you are changing your working copy from one -# location to another). In these cases, the last path must be used as -# reference whenever it doesn't point to user's bin directory. This is -# another reason to provide the centos-art.sh absolute path when you -# execute the prepare function. -if [[ ! $TCAR_WORKDIR =~ "^$(dirname $0)" ]] \ - && [[ ! $(dirname $0) =~ "^${HOME}/bin" ]];then - TCAR_WORKDIR=$(dirname $0 | sed "s,/${TCAR_BASHSCRIPTS},,") -fi - -# Redefine the working copy absolute path considering the (Subversion) -# previous directory structures used in the repository. -if [[ -d ${TCAR_WORKDIR}/trunk ]];then - TCAR_WORKDIR=${TCAR_WORKDIR}/trunk -fi +# Initialize default configuration values. +. $(dirname ${0})/centos-art.conf -# Initialize repository brand information. -if [[ ! $TCAR_BRAND ]] || [[ $TCAR_BRAND == "" ]];then - TCAR_BRAND='centos' +# Initialize user-specific configuration values. +if [[ -f ${TCAR_USER_CONFIG} ]];then + . ${TCAR_USER_CONFIG} fi -# Initialize script-specific configuration variables. -declare -xr CLI_NAME="${TCAR_BRAND}-art" -declare -xr CLI_VERSION='0.4' -declare -xr CLI_LANG_LC=$(echo ${LANG} | cut -d'.' -f1) -declare -xr CLI_LANG_LL=$(echo ${CLI_LANG_LC} | cut -d'_' -f1) -declare -xr CLI_LANG_CC=$(echo ${CLI_LANG_LC} | cut -d'_' -f2) -declare -xr CLI_BASEDIR="${TCAR_WORKDIR}/${TCAR_BASHSCRIPTS}" -declare -xr CLI_FUNCDIR="${CLI_BASEDIR}/Functions" - # Initialize internationalization through GNU gettext. . gettext.sh -declare -xr TEXTDOMAIN=${CLI_NAME}.sh -declare -xr TEXTDOMAINDIR=${TCAR_WORKDIR}/Locales/${TCAR_BASHSCRIPTS} - -# Initialize absolute path to temporal directory. -declare -xr TMPDIR="$(mktemp -p /tmp -d ${CLI_NAME}.sh-XXXXXX)" - -# Initialize command-line interface. -if [[ -x ${CLI_FUNCDIR}/Commons/cli.sh ]];then - . ${CLI_FUNCDIR}/Commons/cli.sh; export -f 'cli'; cli "$@" +declare -xr TEXTDOMAIN=${TCAR_CLI_NAME} +declare -xr TEXTDOMAINDIR=${TCAR_CLI_L10NDIR} + +# Initialize the centos-art.sh script command-line interface. +if [[ -x ${TCAR_CLI_INIT_FILE} ]];then + . ${TCAR_CLI_INIT_FILE}; export -f ${TCAR_CLI_INIT_FUNCTION} + ${TCAR_CLI_INIT_FUNCTION} "$@" +else + echo "${TCAR_CLI_INIT_FILE} `gettext "has not execution rights."`" fi diff --git a/Automation/centos-art.sh-mods/Cli/cli.sh b/Automation/centos-art.sh-mods/Cli/cli.sh index 9d9a17d..86197ac 100755 --- a/Automation/centos-art.sh-mods/Cli/cli.sh +++ b/Automation/centos-art.sh-mods/Cli/cli.sh @@ -1,9 +1,13 @@ #!/bin/bash +###################################################################### # -# cli.sh -- This function initiates the centos-art.sh script -# command-line interface. Variables defined in this function are -# accesible by all other functions. The cli function is the first -# script executed by centos-art.sh, onces executed in a terminal. +# cli.sh -- This function initiates the centos-art.sh script +# command-line interface. This is the first script the centos-art.sh +# runs, onces it has been executed in a terminal. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,56 +25,23 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli { - # Initialize global variables. - local CLI_FUNCNAME='' - local CLI_FUNCDIRNAM='' - local CLI_FUNCSCRIPT='' - local ARGUMENTS='' - - # Initialize default value to filter flag. The filter flag - # (--filter) is used mainly to reduce the number of files to - # process. The value of this variable is interpreted as - # egrep-posix regular expression. By default, when the --filter - # option is not provided, all paths in the working copy must match - # except files under hidden directories like `.svn'. We do this in - # conjunction with `cli_getFilesList', when building the list of - # files that will be processed. - local FLAG_FILTER='[[:alnum:]_/-]+' - - # Initialize default value to verbosity flag. The verbosity flag - # (-v | --verbose) controls whether centos-art.sh script prints - # messages or not. By default, all messages are suppressed except - # those directed to standard error. - local FLAG_QUIET='false' - - # Initialize default value to answer flag. The answer flag - # (--answer-yes) controls whether centos-art.sh script does or - # does not pass confirmation request points. By default, it - # doesn't. - local FLAG_ANSWER='false' - - # Initialize default value to commit changes flag. This flag - # (--synchronize) controls whether version control system is - # triggered or not after realizing changes to source files under - # version control. - local FLAG_SYNCHRONIZE='false' + local CLI_FUNCTION_NAME='' + local CLI_FUNCTION_DIR='' + local CLI_FUNCTION_FILE='' + local CLI_FUNCTION='' + local CLI_FUNCTIONS=$(ls ${TCAR_CLI_INIT_DIR}/${TCAR_CLI_INIT_FUNCTION}_*.sh) # Initialize list of common functionalities to load. - local FILES=$(ls ${CLI_FUNCDIR}/Commons/*.sh) - - # Initialize common functionalities. - for FILE in ${FILES};do - if [[ -x ${FILE} ]];then - . ${FILE} - export -f $(grep '^function ' ${FILE} | cut -d' ' -f2) + for CLI_FUNCTION in ${CLI_FUNCTIONS};do + if [[ -x ${CLI_FUNCTION} ]];then + . ${CLI_FUNCTION} + export -f $(grep '^function ' ${CLI_FUNCTION} | cut -d' ' -f2) else - echo "`eval_gettext "The \\\$FILE needs to have execution rights."`" + echo "${CLI_FUNCTION} `gettext "has not execution rights."`" exit fi done @@ -85,52 +56,61 @@ function cli { # `Ctrl+C'). trap cli_terminateScriptExecution 0 - # Redefine ARGUMENTS variable using current positional parameters. - cli_parseArgumentsReDef "$@" + # Initialize variable holding arguments passed to centos-art.sh + # command-line interface. + local CLI_FUNCTION_ARGUMENTS='' + + # Redefine arguments using current positional parameters. + cli_setArguments "${@}" + + # Redefine positional parameters using arguments variable. + eval set -- "${CLI_FUNCTION_ARGUMENTS}" # Check function name. The function name is critical for # centos-art.sh script to do something coherent. If it is not # provided, execute the help functionality and end script # execution. - if [[ ! "$1" ]] || [[ ! "$1" =~ '^[[:alpha:]]' ]];then + if [[ ! "${1}" ]] || [[ ! "${1}" =~ '^[[:alpha:]]' ]];then cli_runFnEnvironment help --read --format="texinfo" tcar-fs::: exit fi - # Define function name (CLI_FUNCNAME) using the first argument in + # Define function name (CLI_FUNCTION_NAME) using the first argument in # the command-line. - CLI_FUNCNAME=$(cli_getRepoName $1 -f | cut -d '-' -f1) + CLI_FUNCTION_NAME=$(cli_getRepoName ${1} -f | cut -d '-' -f1) # Define function directory. - CLI_FUNCDIRNAM=$(cli_getRepoName $CLI_FUNCNAME -d) + CLI_FUNCTION_DIR=$(cli_getRepoName ${CLI_FUNCTION_NAME} -d) # Define function file name. - CLI_FUNCSCRIPT=${CLI_FUNCDIR}/${CLI_FUNCDIRNAM}/${CLI_FUNCNAME}.sh + CLI_FUNCTION_FILE=${TCAR_CLI_MODSDIR}/${CLI_FUNCTION_DIR}/${CLI_FUNCTION_NAME}.sh # Check function script execution rights. - cli_checkFiles -x "${CLI_FUNCSCRIPT}" + cli_checkFiles -x ${CLI_FUNCTION_FILE} # Remove the first argument passed to centos-art.sh command-line # in order to build optional arguments inside functionalities. We # start counting from second argument (inclusive) on. shift 1 - # Redefine ARGUMENTS using current positional parameters. - cli_parseArgumentsReDef "$@" + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" # Define default text editors used by centos-art.sh script. - if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then - EDITOR='/usr/bin/vim' + if [[ ! "${TCAR_USER_EDITOR}" =~ '/usr/bin/(vim|emacs|nano)' ]];then + TCAR_USER_EDITOR='/usr/bin/vim' fi # Check text editor execution rights. - cli_checkFiles -x ${EDITOR} + cli_checkFiles -x ${TCAR_USER_EDITOR} # Go for function initialization. Keep the cli_exportFunctions # function calling after all variables and arguments definitions. - cli_exportFunctions "${CLI_FUNCDIRNAM}/${CLI_FUNCNAME}" + cli_exportFunctions "${CLI_FUNCTION_DIR}/${CLI_FUNCTION_NAME}" # Execute function. - $CLI_FUNCNAME + ${CLI_FUNCTION_NAME} } diff --git a/Automation/centos-art.sh-mods/Cli/cli_checkFiles.sh b/Automation/centos-art.sh-mods/Cli/cli_checkFiles.sh index 3c65ed4..e7afc36 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_checkFiles.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_checkFiles.sh @@ -1,12 +1,17 @@ #!/bin/bash +###################################################################### # -# cli_checkFiles.sh -- This function standardizes the way file -# conditional expressions are applied inside centos-art.sh script. -# Here is where we answer questions like: is the file a regular file -# or a directory? Or, is it a symbolic link? Or even, does it have -# execution rights, etc. If the verification fails somehow at any -# point, an error message is output and centos-art.sh script finishes -# its execution. +# cli_checkFiles.sh -- This function standardizes the way file +# conditional expressions are applied to files. Here is where +# centos-art.sh script answers questions like: is the file a regular +# file or a directory? Or, is it a symbolic link? Or even, does it +# have execution rights, etc. If the verification fails somehow at +# any point, an error message is output and centos-art.sh script +# finishes its execution. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -24,9 +29,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_checkFiles { @@ -36,32 +39,30 @@ function cli_checkFiles { # Define long options. local ARGSL='mime:,is-versioned,match:,is-installed' - # Initialize array variables. + # Initialize local array variables. local -a CONDITION_COMMAND local -a CONDITION_PATTERN local -a CONDITION_MESSAGE - # Initialize array variable counter. + # Initialize local counter. local COUNTER=0 # Initialize arguments with an empty value and set it as local # variable to this function scope. Doing this is very important to - # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS for getopt. - cli_parseArgumentsReDef "$@" - - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments + # avoid any clash with higher execution environments. This + # variable is shared for different function environments. + local CLI_FUNCTION_ARGUMENTS='' + + # Redefine arguments using current positional parameters. + cli_setArguments "${@}" - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" + # Redefine positional parameters using arguments variable. + eval set -- "${CLI_FUNCTION_ARGUMENTS}" # Look for options passed through positional parameters. while true; do - case "$1" in + case "${1}" in -d ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='test' @@ -99,16 +100,16 @@ function cli_checkFiles { ;; -i | --mime ) - local MIME=$2 + local MIME=${2} CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='file' CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]='-bi' - CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "isn't a \\\"\\\$MIME\\\" file."`" + CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "isn't a \\\"\\\${MIME}\\\" file."`" shift 2 ;; -m | --match ) CONDITION_COMMAND[((++${#CONDITION_COMMAND[*]}))]='match' - CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="$2" + CONDITION_PATTERN[((++${#CONDITION_PATTERN[*]}))]="${2}" CONDITION_MESSAGE[((++${#CONDITION_MESSAGE[*]}))]="`eval_gettext "doesn't match its pattern."`" shift 2 ;; @@ -139,17 +140,17 @@ function cli_checkFiles { # all option-like arguments have been removed from positional # parameters list so we are free to go with the verifications. local FILE='' - local FILES=$@ + local FILES=${@} - for FILE in $FILES;do + for FILE in ${FILES};do until [[ ${COUNTER} -eq ${#CONDITION_PATTERN[*]} ]];do - case ${CONDITION_COMMAND[$COUNTER]} in + case ${CONDITION_COMMAND[${COUNTER}]} in "test" | "rpm" ) - ${CONDITION_COMMAND[$COUNTER]} ${CONDITION_PATTERN[$COUNTER]} ${FILE} \ - || cli_printMessage "${FILE} ${CONDITION_MESSAGE[$COUNTER]}" --as-error-line + ${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE} \ + || cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line ;; "centos-art" ) @@ -157,18 +158,18 @@ function cli_checkFiles { # (that would duplicate them unnecessarily). Instead, # set error messages inside specific functionalities # and use them directly from there. - cli_runFnEnvironment ${CONDITION_PATTERN[$COUNTER]} ${FILE} + cli_runFnEnvironment ${CONDITION_PATTERN[${COUNTER}]} ${FILE} ;; "file" ) - if [[ ! $(${CONDITION_COMMAND[$COUNTER]} ${CONDITION_PATTERN[$COUNTER]} ${FILE}) == "$MIME" ]];then - cli_printMessage "${FILE} ${CONDITION_MESSAGE[$COUNTER]}" --as-error-line + if [[ ! $(${CONDITION_COMMAND[${COUNTER}]} ${CONDITION_PATTERN[${COUNTER}]} ${FILE}) == "${MIME}" ]];then + cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line fi ;; "match" ) - if [[ ! ${FILE} =~ "${CONDITION_PATTERN[$COUNTER]}" ]];then - cli_printMessage "${FILE} ${CONDITION_MESSAGE[$COUNTER]}" --as-error-line + if [[ ! ${FILE} =~ "${CONDITION_PATTERN[${COUNTER}]}" ]];then + cli_printMessage "${FILE} ${CONDITION_MESSAGE[${COUNTER}]}" --as-error-line fi ;; @@ -178,7 +179,7 @@ function cli_checkFiles { esac - COUNTER=$(($COUNTER + 1)) + COUNTER=$((${COUNTER} + 1)) done diff --git a/Automation/centos-art.sh-mods/Cli/cli_checkRepoDirSource.sh b/Automation/centos-art.sh-mods/Cli/cli_checkRepoDirSource.sh index c7a299a..19e434c 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_checkRepoDirSource.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_checkRepoDirSource.sh @@ -1,22 +1,26 @@ #!/bin/bash +###################################################################### # -# cli_checkRepoDirSource.sh -- This function standardizes the path -# construction to directories inside the working copy, using absolute -# paths. This function transforms relative paths passed as non-option -# arguments to centos-art.sh script command-line into absolute paths -# inside the working copy based on whether you are using Subversion or -# Git as version control system. Further verifications, (e.g., whether -# they really exist as directories inside the working copy or not) -# should be realized outside this function. +# cli_checkRepoDirSource.sh -- This function standardizes the path +# construction of directories inside the working copy, using +# absolute paths. This function transforms relative paths passed as +# non-option arguments to centos-art.sh script command-line into +# absolute paths inside the working copy based on whether you are +# using Subversion or Git as version control system. Further +# verifications, (e.g., whether they really exist as directories +# inside the working copy or not) should be realized outside this +# function. # -# NOTE: Transforming relative paths into absolute paths before -# processing them is very useful when you need to execute the -# centos-art.sh script as command (e.g., `centos-art') anywhere -# inside the workstation. +# Use this function whenever you want to be sure non-option +# arguments passed to centos-art.sh script command-line do always +# point to directories inside the working copy. Transforming +# relative paths into absolute paths, before processing them, is +# very useful when you need to execute the centos-art.sh script as +# command (e.g., `centos-art') anywhere on your workstation. # -# Use this function whenever you need to be sure that non-option -# arguments passed to centos-art.sh script command-line will always -# point to directories inside the working copy. +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -34,9 +38,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_checkRepoDirSource { @@ -50,11 +52,11 @@ function cli_checkRepoDirSource { # used as default location). However, it might be useful to use a # dot as argument when you want to include the current location in # a list of arguments to process. - LOCATION=$(echo "$LOCATION" | sed -r "s,^\.$,$(pwd),g") + LOCATION=$(echo "${LOCATION}" | sed -r "s,^\.$,$(pwd),g") # Remove the working directory absolute path from location to # avoid path duplications here. - LOCATION=$(echo "$LOCATION" | sed "s,${TCAR_WORKDIR}/,,g") + LOCATION=$(echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,,g") # When we use Git as version control system, there isn't a need of # using the `trunk', `branches', `tags' convention we were using @@ -81,7 +83,7 @@ function cli_checkRepoDirSource { # messages when we reassign variable values using this function as # reference (e.g., in order to prevent error messages from being # stored inside variables.). - LOCATION=${TCAR_WORKDIR}/${LOCATION} + LOCATION=${TCAR_USER_WRKDIR}/${LOCATION} # Output the absolute path to location. echo "${LOCATION}" diff --git a/Automation/centos-art.sh-mods/Cli/cli_expandTMarkers.sh b/Automation/centos-art.sh-mods/Cli/cli_expandTMarkers.sh index d8b6806..fa9b00b 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_expandTMarkers.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_expandTMarkers.sh @@ -1,10 +1,15 @@ #!/bin/bash +###################################################################### # -# cli_expandTMarkers.sh -- This function standardizes construction of -# translation markers and their related expansion. As convention, -# translation markers must be set inside source files (e.g., Docbook, -# Svg, etc.) and expanded inside temporal instances used to produce -# final contents. +# cli_expandTMarkers.sh -- This function standardizes construction +# of translation markers and their related expansion. As convention, +# translation markers must be set inside source files (e.g., +# Docbook, Svg, etc.) and expanded inside temporal instances used to +# produce final contents. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -22,9 +27,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_expandTMarkers { @@ -36,7 +39,7 @@ function cli_expandTMarkers { local COUNTDST=0 # Define source location on which sed replacements take place. - local LOCATION="$1" + local LOCATION="${1}" # Verify that source location does exist. cli_checkFiles -e ${LOCATION} @@ -66,23 +69,23 @@ function cli_expandTMarkers { # Define theme translation markers. SRC[((++${#SRC[*]}))]='=THEME=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif)" + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif)" SRC[((++${#SRC[*]}))]='=THEMENAME=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-name)" + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif-name)" SRC[((++${#SRC[*]}))]='=THEMERELEASE=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $OUTPUT --motif-release)" + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${OUTPUT} --motif-release)" # Define release-specific translation markers. SRC[((++${#SRC[*]}))]='=RELEASE=' - DST[((++${#DST[*]}))]="$FLAG_RELEASEVER" + DST[((++${#DST[*]}))]="${FLAG_RELEASEVER}" SRC[((++${#SRC[*]}))]='=MAJOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f1)" + DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f1)" SRC[((++${#SRC[*]}))]='=MINOR_RELEASE=' - DST[((++${#DST[*]}))]="$(echo $FLAG_RELEASEVER | cut -d'.' -f2)" + DST[((++${#DST[*]}))]="$(echo ${FLAG_RELEASEVER} | cut -d'.' -f2)" # Define architectures translation markers. SRC[((++${#SRC[*]}))]='=ARCH=' - DST[((++${#DST[*]}))]="$(cli_getPathComponent $FLAG_BASEARCH --architecture)" + DST[((++${#DST[*]}))]="$(cli_getPathComponent ${FLAG_BASEARCH} --architecture)" # Define url translation markers. SRC[((++${#SRC[*]}))]='=URL=' @@ -129,32 +132,32 @@ function cli_expandTMarkers { fi # Define repository translation markers. - SRC[((++${#SRC[*]}))]='=(REPO_TLDIR|REPO_HOME|TCAR_WORKDIR)=' - DST[((++${#DST[*]}))]="${TCAR_WORKDIR}" + SRC[((++${#SRC[*]}))]='=(REPO_TLDIR|REPO_HOME|TCAR_USER_WRKDIR)=' + DST[((++${#DST[*]}))]="${TCAR_USER_WRKDIR}" # Do replacement of nested translation markers. - while [[ $COUNTDST -lt ${#DST[@]} ]];do + while [[ ${COUNTDST} -lt ${#DST[@]} ]];do # Verify existence of translation markers. If there is no # translation marker on replacement, continue with the next # one in the list. - if [[ ! ${DST[$COUNTDST]} =~ '=[A-Z_]+=' ]];then + if [[ ! ${DST[${COUNTDST}]} =~ '=[A-Z_]+=' ]];then # Increment destination counter. - COUNTDST=$(($COUNTDST + 1)) + COUNTDST=$((${COUNTDST} + 1)) # The current replacement value doesn't have translation # marker inside, so skip it and evaluate the next # replacement value in the list. continue fi - while [[ $COUNTSRC -lt ${#SRC[*]} ]];do + while [[ ${COUNTSRC} -lt ${#SRC[*]} ]];do # Update replacements. - DST[$COUNTDST]=$(echo ${DST[$COUNTDST]} \ - | sed -r "s!${SRC[$COUNTSRC]}!${DST[$COUNTSRC]}!g") + DST[${COUNTDST}]=$(echo ${DST[${COUNTDST}]} \ + | sed -r "s!${SRC[${COUNTSRC}]}!${DST[${COUNTSRC}]}!g") # Increment source counter. - COUNTSRC=$(($COUNTSRC + 1)) + COUNTSRC=$((${COUNTSRC} + 1)) done @@ -162,7 +165,7 @@ function cli_expandTMarkers { COUNTSRC=0 # Increment destination counter. - COUNTDST=$(($COUNTDST + 1)) + COUNTDST=$((${COUNTDST} + 1)) done @@ -171,10 +174,10 @@ function cli_expandTMarkers { # Use sed to replace translation markers inside the design # model instance. - sed -r -i "s!${SRC[$COUNT]}!${DST[$COUNT]}!g" ${LOCATION} + sed -r -i "s!${SRC[${COUNT}]}!${DST[${COUNT}]}!g" ${LOCATION} # Increment counter. - COUNT=$(($COUNT + 1)) + COUNT=$((${COUNT} + 1)) done diff --git a/Automation/centos-art.sh-mods/Cli/cli_exportFunctions.sh b/Automation/centos-art.sh-mods/Cli/cli_exportFunctions.sh index 1af3c72..fc90159 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_exportFunctions.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_exportFunctions.sh @@ -1,8 +1,13 @@ #!/bin/bash +###################################################################### # -# cli_exportFunctions.sh -- This function standardizes the way -# specific functionalities are exported to centos-art.sh script -# environment. +# cli_exportFunctions.sh -- This function standardizes the way +# specific functionalities are exported to centos-art.sh script +# environment. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -20,76 +25,75 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_exportFunctions { # Retrieve export identifier for the function we want to export. - local EXPORTID="$1" + local FUNCTION_EXPORTID="${1}" # Verify the export identification existence. This argument must # be passed as first argument and match a relative path format. - if [[ ! $EXPORTID =~ '^[A-Z][[:alpha:]]+(/[[:alpha:]_]+)+$' ]];then - cli_printMessage "`gettext "The export id doesn't match its pattern."`" --as-error-line + if [[ ! ${FUNCTION_EXPORTID} =~ '^[A-Z][[:alpha:]]+(/[[:alpha:]_]+)+$' ]];then + cli_printMessage "`gettext "The function's export id doesn't match its pattern."`" --as-error-line fi # Define the source location where function files are placed in. - local LOCATION=${CLI_FUNCDIR}/$(dirname ${EXPORTID}) + local FUNCTION_LOCATION=${TCAR_CLI_MODSDIR}/$(dirname ${FUNCTION_EXPORTID}) # Define suffix used to retrieve function files. - local SUFFIX=$(basename "$EXPORTID") + local FUNCTION_SUFFIX=$(basename "${FUNCTION_EXPORTID}") # Verify the suffix value used to retrieve function files. # Assuming no suffix value is passed as second argument to this - # function, use the function name value (CLI_FUNCNAME) as default + # function, use the function name value (CLI_FUNCTION_NAME) as default # value. - if [[ $SUFFIX == '' ]];then - SUFFIX="${CLI_FUNCNAME}" + if [[ -z ${FUNCTION_SUFFIX} ]];then + FUNCTION_SUFFIX="${CLI_FUNCTION_NAME}" fi # Redefine suffix to match all related function files inside the # related function directory. - SUFFIX=${SUFFIX}'[[:alpha:]_]*' + FUNCTION_SUFFIX=${FUNCTION_SUFFIX}'[[:alpha:]_]*' # Define the pattern used to retrieve function names from function # files. - local PATTERN="^function[[:space:]]+${SUFFIX}[[:space:]]+{[[:space:]]*$" + local FUNCTION_PATTERN="^function[[:space:]]+${FUNCTION_SUFFIX}[[:space:]]+{[[:space:]]*$" # Define the list of files. - local FUNCFILE='' - local FUNCFILES=$(cli_getFilesList ${LOCATION} --pattern="${LOCATION}/${SUFFIX}\.sh$" \ + local FUNCTION_FILE='' + local FUNCTION_FILES=$(cli_getFilesList ${FUNCTION_LOCATION} \ + --pattern="${FUNCTION_LOCATION}/${FUNCTION_SUFFIX}\.sh$" \ --maxdepth='1' --mindepth='1' --type='f') # Verify the list of files. If no function file exists for the # location specified stop the script execution. Otherwise the # script will surely try to execute a function that haven't been # exported yet and report an error about it. - if [[ $FUNCFILES == '' ]];then + if [[ -z ${FUNCTION_FILES} ]];then cli_printMessage "${FUNCNAME}: `gettext "No function file was found."`" --as-error-line fi # Process the list of files. - for FUNCFILE in $FUNCFILES;do + for FUNCTION_FILE in ${FUNCTION_FILES};do # Verify the execution rights for function file. - cli_checkFiles -x ${FUNCFILE} + cli_checkFiles -x ${FUNCTION_FILE} # Verify that function files have not been already exported. # If they have been already exported don't export them again. # Instead, continue with the next function file in the list. - declare -F | gawk '{ print $3 }' | egrep "^${FUNCFILE}$" > /dev/null + declare -F | gawk '{ print $3 }' | egrep "^${FUNCTION_FILE}$" > /dev/null if [[ $? -eq 0 ]];then continue fi # Initialize the function file. - . ${FUNCFILE} + . ${FUNCTION_FILE} # Export the function names inside the file to current shell # script environment. - export -f $(egrep "${PATTERN}" ${FUNCFILE} | gawk '{ print $2 }') + export -f $(egrep "${FUNCTION_PATTERN}" ${FUNCTION_FILE} | gawk '{ print $2 }') done diff --git a/Automation/centos-art.sh-mods/Cli/cli_getConfigLines.sh b/Automation/centos-art.sh-mods/Cli/cli_getConfigLines.sh index 2d9b636..46a1783 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getConfigLines.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getConfigLines.sh @@ -1,16 +1,21 @@ #!/bin/bash +###################################################################### # -# cli_getConfigLines.sh -- This function standardizes the way -# configuration lines are retrieved form configuration files. As -# arguments, the configuration file absolute path, the configuration -# section name, and the configuration option name must be provided. +# cli_getConfigLines.sh -- This function standardizes the way +# configuration lines are retrieved form configuration files. As +# arguments, the configuration file absolute path, the configuration +# section name, and the configuration option name must be provided. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # # 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. +# 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 @@ -21,47 +26,45 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - +###################################################################### + function cli_getConfigLines { # Initialize absolute path to configuration file. - local CONFIG_ABSPATH="$1" + local CONFIGURATION_FILE="${1}" # Verify that configuration file does exist. - cli_checkFiles -e ${CONFIG_ABSPATH} + cli_checkFiles -e ${CONFIGURATION_FILE} # Initialize configuration section name where the variable value # we want to to retrieve is set in. - local CONFIG_SECTION="$2" + local CONFIGURATION_SECTION="${2}" # Be sure the configuration section name has the correct format. - if [[ ! $CONFIG_SECTION =~ '^[[:alnum:]._-]+$' ]];then + if [[ ! ${CONFIGURATION_SECTION} =~ '^[[:alnum:]._-]+$' ]];then cli_printMessage "`gettext "The configuration section provided is incorrect."`" --as-error-line fi # Initialize variable name we want to retrieve value from. - local CONFIG_OPTION="$3" + local CONFIGURATION_OPTION="${3}" # Verify configuration variable name. When no variable name is # provided print all configuration lines that can be considered as # well-formed paths. Be sure configuration variable name starts # just at the beginning of the line. - if [[ ! $CONFIG_OPTION =~ '^[[:alnum:]_./-]+$' ]];then - CONFIG_OPTION='[[:alnum:]_./-]+[[:space:]]*=' + if [[ ! ${CONFIGURATION_OPTION} =~ '^[[:alnum:]_./-]+$' ]];then + CONFIGURATION_OPTION='[[:alnum:]_./-]+[[:space:]]*=' fi # Retrieve configuration lines from configuration file. - local CONFIG_LINES=$(cat ${CONFIG_ABSPATH} \ + local CONFIGURATION_LINES=$(cat ${CONFIGURATION_FILE} \ | egrep -v '^#' \ | egrep -v '^[[:space:]]*$' \ - | sed -r -n "/^\[${CONFIG_SECTION}\][[:space:]]*$/,/^\[/p" \ + | sed -r -n "/^\[${CONFIGURATION_SECTION}\][[:space:]]*$/,/^\[/p" \ | egrep -v '^\[' | sort | uniq \ - | egrep "^${CONFIG_OPTION}") + | egrep "^${CONFIGURATION_OPTION}") # Output value related to variable name. - echo "$CONFIG_LINES" + echo "${CONFIGURATION_LINES}" } diff --git a/Automation/centos-art.sh-mods/Cli/cli_getConfigSectionNames.sh b/Automation/centos-art.sh-mods/Cli/cli_getConfigSectionNames.sh index a280736..387defc 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getConfigSectionNames.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getConfigSectionNames.sh @@ -1,9 +1,14 @@ #!/bin/bash +###################################################################### # -# cli_getConfigSectionNames.sh -- This function standardizes the way -# section names are retrieved from configuration files. Once section -# names are retrieved they are printed to standard output for further -# processing. +# cli_getConfigSectionNames.sh -- This function standardizes the way +# section names are retrieved from configuration files. Once section +# names are retrieved they are printed to standard output for +# further processing. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,21 +26,19 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_getConfigSectionNames { # Define absolute path to configuration file we want to retrieve # section names from. - local CONF_FILE=$1 + local CONFIGURATION_FILE=${1} # Verify existence of configuration file. - cli_checkFiles $CONF_FILE -f + cli_checkFiles ${CONFIGURATION_FILE} -f # Output all section names without brackets, one per line. - egrep '^\[[[:alnum:]._-]+\][[:space:]]*$' $CONF_FILE \ + egrep '^\[[[:alnum:]._-]+\][[:space:]]*$' ${CONFIGURATION_FILE} \ | sed -r 's/\[(.+)\]/\1/' } diff --git a/Automation/centos-art.sh-mods/Cli/cli_getConfigValue.sh b/Automation/centos-art.sh-mods/Cli/cli_getConfigValue.sh index 08065ae..82b3127 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getConfigValue.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getConfigValue.sh @@ -1,9 +1,14 @@ #!/bin/bash +###################################################################### # -# cli_getConfigValue.sh -- This function standardizes the way configuration -# files are retrieved from configuration files. As arguments, the -# configuration file absolute path, the configuration section name, and the -# configuration option name must be provided. +# cli_getConfigValue.sh -- This function standardizes the way +# configuration values are retrieved from configuration files. As +# arguments, the configuration file absolute path, the configuration +# section name, and the configuration option name must be provided. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,33 +26,31 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - +###################################################################### + function cli_getConfigValue { # Initialize absolute path to configuration file. - local CONFIG_ABSPATH="$1" + local CONFIGURATION_FILE="${1}" # Initialize configuration section name where the variable value # we want to to retrieve is set in. - local CONFIG_SECTION="$2" + local CONFIGURATION_SECTION="${2}" # Initialize variable name we want to retrieve value from. - local CONFIG_OPTION="$3" + local CONFIGURATION_OPTION="${3}" # Retrieve configuration lines from configuration file. - local CONFIG_LINES=$(cli_getConfigLines \ - "$CONFIG_ABSPATH" "$CONFIG_SECTION" "$CONFIG_OPTION") + local CONFIGURATION_LINES=$(cli_getConfigLines \ + "${CONFIGURATION_FILE}" "${CONFIGURATION_SECTION}" "${CONFIGURATION_OPTION}") # Parse configuration lines to retrieve the values of variable # names. - local CONFIG_VALUE=$(echo $CONFIG_LINES \ + local CONFIGURATION_VALUE=$(echo ${CONFIGURATION_LINES} \ | cut -d= -f2- \ | sed -r -e 's/"//g' -e 's/^[[:space:]]*//' -e 's/[[:space:]]*$//' ) # Output values related to variable name. - echo "$CONFIG_VALUE" + echo "${CONFIGURATION_VALUE}" } diff --git a/Automation/centos-art.sh-mods/Cli/cli_getFilesList.sh b/Automation/centos-art.sh-mods/Cli/cli_getFilesList.sh index 8a6e42b..ebbced4 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getFilesList.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getFilesList.sh @@ -1,9 +1,14 @@ #!/bin/bash +###################################################################### # -# cli_getFilesList.sh -- This function standardizes the way list of -# files are built inside centos-art.sh script. This function outputs a -# sorted and unique list of files based on the options and locations -# passed as argument. +# cli_getFilesList.sh -- This function standardizes the way list of +# files are built inside centos-art.sh script. This function outputs +# a sorted and unique list of files based on the options and +# locations passed as argument. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,9 +26,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_getFilesList { @@ -34,7 +37,7 @@ function cli_getFilesList { local ARGSL='pattern:,mindepth:,maxdepth:,type:,uid:' # Initialize pattern used to reduce the find output. - local PATTERN="$FLAG_FILTER" + local PATTERN="${TCAR_FLAG_FILTER}" # Initialize options used with find command. local OPTIONS='' @@ -42,42 +45,41 @@ function cli_getFilesList { # Initialize arguments with an empty value and set it as local # variable to this function scope. Doing this is very important to # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS for getopt. - cli_parseArgumentsReDef "$@" + local CLI_FUNCTION_ARGUMENTS='' - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" + # Redefine positional parameters using CLI_FUNCTION_ARGUMENTS variable. + eval set -- "${CLI_FUNCTION_ARGUMENTS}" while true;do - case "$1" in + case "${1}" in --pattern ) - PATTERN="$2" + PATTERN="${2}" shift 2 ;; --maxdepth ) - OPTIONS="$OPTIONS -maxdepth $2" + OPTIONS="${OPTIONS} -maxdepth ${2}" shift 2 ;; --mindepth ) - OPTIONS="$OPTIONS -mindepth $2" + OPTIONS="${OPTIONS} -mindepth ${2}" shift 2 ;; --type ) - OPTIONS="$OPTIONS -type $2" + OPTIONS="${OPTIONS} -type ${2}" shift 2 ;; --uid ) - OPTIONS="$OPTIONS -uid $2" + OPTIONS="${OPTIONS} -uid ${2}" shift 2 ;; @@ -92,10 +94,9 @@ function cli_getFilesList { # removed from positional parameters. Only non-option arguments # remain so we use them as source location for find command to # look files for. - local LOCATIONS=$@ # Verify that locations does exist. - cli_checkFiles -e ${LOCATIONS} + cli_checkFiles -e ${@} # Redefine pattern as regular expression. When we use regular # expressions with find, regular expressions are evaluated against @@ -105,11 +106,11 @@ function cli_getFilesList { # option in the command-line could be a tedious task. Instead, in # the sake of reducing some typing, we prepare the regular # expression here to match the whole path using the regular - # expression provided by the user as pattern. Do not use LOCATION - # variable as part of regular expression so it could be possible - # to use path expansion. Using path expansion reduce the amount - # of places to find out things and so the time required to finish - # the task. + # expression provided by the user as pattern. Do not use locations + # as part of regular expression so it could be possible to use + # path expansion. Using path expansion reduce the amount of + # places to find out things and so the time required to finish the + # task. # # Don't do such path expansion here. Instead, do it when you call # this function. Otherwise you would be prohibiting the @@ -117,9 +118,9 @@ function cli_getFilesList { #PATTERN="^/.*${PATTERN}$" # Define list of files to process. At this point we cannot verify - # whether the LOCATION is a directory or a file since path + # whether the location is a directory or a file since path # expansion could be introduced to it. The best we can do is # verifying exit status and go on. - find ${LOCATIONS} -regextype posix-egrep ${OPTIONS} -regex "${PATTERN}" | sort | uniq + find ${@} -regextype posix-egrep ${OPTIONS} -regex "${PATTERN}" | sort | uniq } diff --git a/Automation/centos-art.sh-mods/Cli/cli_getLocalizationDir.sh b/Automation/centos-art.sh-mods/Cli/cli_getLocalizationDir.sh index 42c4456..91ec8eb 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getLocalizationDir.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getLocalizationDir.sh @@ -1,15 +1,21 @@ #!/bin/bash +###################################################################### # -# cli_getLocalizationDir.sh -- This function standardizes the way -# localization paths are created. The first argument of this function -# must be a path pointing a directory inside the repository. +# cli_getLocalizationDir.sh -- This function standardizes the way +# localization paths are created. The first argument of this +# function must be a path pointing a directory inside the +# repository. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # # 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. +# 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 @@ -20,9 +26,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_getLocalizationDir { diff --git a/Automation/centos-art.sh-mods/Cli/cli_getPathComponent.sh b/Automation/centos-art.sh-mods/Cli/cli_getPathComponent.sh index cb262dd..5bf6868 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getPathComponent.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getPathComponent.sh @@ -1,10 +1,15 @@ #!/bin/bash +###################################################################### # -# cli_getPathComponent.sh -- This function standardizes the way -# directory structures are organized inside the working copy of CentOS -# Artwork Repository. You can use this function to retrieve -# information from paths (e.g., releases, architectures and theme -# artistic motifs) or the patterns used to build the paths. +# cli_getPathComponent.sh -- This function standardizes the way +# directory structures are organized inside the working copy of +# CentOS Artwork Repository. You can use this function to retrieve +# information from paths (e.g., releases, architectures and theme +# artistic motifs) or the patterns used to build the paths. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -22,9 +27,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_getPathComponent { @@ -48,39 +51,38 @@ function cli_getPathComponent { # Initialize arguments with an empty value and set it as local # variable to this function scope. Doing this is very important to # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS variable for getopt. - cli_parseArgumentsReDef "$@" + local CLI_FUNCTION_ARGUMENTS='' - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" + # Redefine positional parameters using CLI_FUNCTION_ARGUMENTS variable. + eval set -- "${CLI_FUNCTION_ARGUMENTS}" # Define location we want to apply verifications to. - local LOCATION=$(echo $@ | sed -r 's!^.*--[[:space:]](.+)$!\1!') + local LOCATION=$(echo ${@} | sed -r 's!^.*--[[:space:]](.+)$!\1!') # Look for options passed through positional parameters. while true;do - case "$1" in + case "${1}" in --release ) - echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\1!" + echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\1!" shift 1 break ;; --release-major ) - echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\2!" + echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\2!" shift 1 break ;; --release-minor ) - echo "$LOCATION" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\4!" + echo "${LOCATION}" | egrep "${RELEASE}" | sed -r "s!.*/${RELEASE}/.*!\4!" shift 1 break ;; @@ -92,7 +94,7 @@ function cli_getPathComponent { ;; --architecture ) - echo "$LOCATION" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!" + echo "${LOCATION}" | egrep "${ARCHITECTURE}" | sed -r "s!${ARCHITECTURE}!\1!" shift 1 break ;; @@ -104,19 +106,19 @@ function cli_getPathComponent { ;; --motif ) - echo "$LOCATION" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\1!" + echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\1!" shift 1 break ;; --motif-name ) - echo "$LOCATION" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\2!" + echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\2!" shift 1 break ;; --motif-release ) - echo "$LOCATION" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\3!" + echo "${LOCATION}" | egrep "${THEME_MOTIF}" | sed -r "s!.*${THEME_MOTIF}.*!\3!" shift 1 break ;; @@ -128,7 +130,7 @@ function cli_getPathComponent { ;; --repo-dir ) - echo "${LOCATION}" | sed "s,${TCAR_WORKDIR}/,," + echo "${LOCATION}" | sed "s,${TCAR_USER_WRKDIR}/,," shift 1 break ;; diff --git a/Automation/centos-art.sh-mods/Cli/cli_getRepoName.sh b/Automation/centos-art.sh-mods/Cli/cli_getRepoName.sh index 3680252..ebbe5d2 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getRepoName.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getRepoName.sh @@ -1,11 +1,16 @@ #!/bin/bash +###################################################################### # -# cli_getRepoName.sh -- This function standardizes files and -# directories name convection inside the working copy of CentOS -# Artowrk Repository. As convection, regular files are written in -# lower-case and directories are written capitalized. Use this -# function to sanitate the name of regular files and directories on -# paths you work with. +# cli_getRepoName.sh -- This function standardizes files and +# directories name convection inside the working copy of CentOS +# Artowrk Repository. As convection, regular files are written in +# lower-case and directories are written capitalized. Use this +# function to sanitate the name of regular files and directories on +# paths you work with. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -23,35 +28,33 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_getRepoName { # Define the name we want to apply verifications to. - local NAME="$1" + local NAME="${1}" # Avoid using options as it were names. When name value is empty # but an option is provided, the option becomes the first # positional argument and is evaluated as it were a name which is # something we need to prevent from happening. - if [[ $NAME =~ '^-' ]];then + if [[ ${NAME} =~ '^-' ]];then return fi # Look for options passed through positional parameters. - case "$2" in + case "${2}" in -f|--basename ) # Reduce the path passed to use just the non-directory # part of it (i.e., the last component in the path; _not_ # the last "real" directory in the path). - NAME=$(basename $NAME) + NAME=$(basename ${NAME}) # Clean value. - NAME=$(echo $NAME \ + NAME=$(echo ${NAME} \ | tr -s ' ' '_' \ | tr '[:upper:]' '[:lower:]') ;; @@ -73,7 +76,7 @@ function cli_getRepoName { # directory part in the path. Assuming there is no # directory part but a non-empty value in the path, use # that value as directory part and clean it up. - if [[ $NAME =~ '.+/.+' ]];then + if [[ ${NAME} =~ '.+/.+' ]];then # When path information is reduced, we need to # consider that absolute paths contain some @@ -82,12 +85,12 @@ function cli_getRepoName { # /home/centos, /home/centos/artwork, # /home/centos/artwork/turnk, trunk, etc.) So, we keep # them unchanged for later use. - PREFIXDIR=$(echo $NAME \ - | sed -r "s,^((${TCAR_WORKDIR}/)?(trunk|branches|tags)/)?.+$,\1,") + PREFIXDIR=$(echo ${NAME} \ + | sed -r "s,^((${TCAR_USER_WRKDIR}/)?(trunk|branches|tags)/)?.+$,\1,") # ... and remove them from the path information we do # want to sanitate. - DIRS=$(dirname "$NAME" \ + DIRS=$(dirname "${NAME}" \ | sed -r "s!^${PREFIXDIR}!!" \ | tr '/' ' ') @@ -96,14 +99,14 @@ function cli_getRepoName { # At this point, there is not directory part in the # information passed, so use the value passed as # directory part as such. - DIRS=$NAME + DIRS=${NAME} fi - for DIR in $DIRS;do + for DIR in ${DIRS};do # Sanitate directory component. - if [[ $DIR =~ '^[a-z]' ]];then + if [[ ${DIR} =~ '^[a-z]' ]];then DIR=$(echo ${DIR} \ | tr -s ' ' '_' \ | tr '[:upper:]' '[:lower:]' \ @@ -111,7 +114,7 @@ function cli_getRepoName { fi # Rebuild path using sanitized values. - CLEANDIRS="${CLEANDIRS}/$DIR" + CLEANDIRS="${CLEANDIRS}/${DIR}" done @@ -120,7 +123,7 @@ function cli_getRepoName { # Add prefix directory information to sanitate path # information. - if [[ "$PREFIXDIR" != '' ]];then + if [[ "${PREFIXDIR}" != '' ]];then NAME=${PREFIXDIR}${NAME} fi ;; @@ -128,6 +131,6 @@ function cli_getRepoName { esac # Print out the clean path string. - echo $NAME + echo ${NAME} } diff --git a/Automation/centos-art.sh-mods/Cli/cli_getTemporalFile.sh b/Automation/centos-art.sh-mods/Cli/cli_getTemporalFile.sh index 73849ce..502eb91 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_getTemporalFile.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_getTemporalFile.sh @@ -1,15 +1,21 @@ #!/bin/bash +###################################################################### # -# cli_getTemporalFile.sh -- This function returns the absolute path -# you need to use to create temporal files. Use this function whenever -# you need to create temporal files inside centos-art.sh script. +# cli_getTemporalFile.sh -- This function returns the absolute path +# you need to use to create temporal files. Use this function +# whenever you need to create temporal files inside centos-art.sh +# script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # # 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. +# 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 @@ -20,9 +26,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_getTemporalFile { @@ -30,18 +34,18 @@ function cli_getTemporalFile { # instances are created previous to be parsed by inkscape in order # to be exported as png. In such cases .svg file extension is # required in order to avoid complains from inkscape. - local NAME="$(cli_getRepoName $1 -f)" + local NAME="$(cli_getRepoName ${1} -f)" # Check default base name for temporal file, it can't be an empty # value. - if [[ "$NAME" == '' ]];then + if [[ "${NAME}" == '' ]];then cli_printMessage "`gettext "The first argument cannot be empty."`" --as-error-line fi # Define absolute path for temporal file. - local TEMPFILE="${TMPDIR}/${NAME}" + local TEMPFILE="${TCAR_CLI_TEMPDIR}/${NAME}" # Output absolute path to final temporal file. - echo $TEMPFILE + echo ${TEMPFILE} } diff --git a/Automation/centos-art.sh-mods/Cli/cli_printCaller.sh b/Automation/centos-art.sh-mods/Cli/cli_printCaller.sh new file mode 100755 index 0000000..ef3bace --- /dev/null +++ b/Automation/centos-art.sh-mods/Cli/cli_printCaller.sh @@ -0,0 +1,57 @@ +#!/bin/bash +###################################################################### +# +# cli_printCaller.sh -- This function standardizes the way caller +# information is retrieved. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +###################################################################### + +function cli_printCaller { + + local EXPR=${1} + local OPTS=${2} + + case ${OPTS} in + + --line ) + caller ${EXPR} | gawk '{ print $1 }' + ;; + + --name ) + caller ${EXPR} | gawk '{ print $2 }' + ;; + + --path ) + caller ${EXPR} | gawk '{ print $3 }' + ;; + + * ) + # Define where the error was originated inside the + # centos-art.sh script. Print out the function name and + # line from the caller. + caller ${EXPR} | gawk '{ print $2 " L." $1 }' + ;; + + esac + +} diff --git a/Automation/centos-art.sh-mods/Cli/cli_printCopyrightInfo.sh b/Automation/centos-art.sh-mods/Cli/cli_printCopyrightInfo.sh index 078bc05..bdd11e7 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_printCopyrightInfo.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_printCopyrightInfo.sh @@ -1,18 +1,23 @@ #!/bin/bash +###################################################################### # -# cli_printCopyrightInfo.sh -- This function standardizes the -# copyright information printed on content produced by centos-art.sh -# script. +# cli_printCopyrightInfo.sh -- This function standardizes the +# copyright information printed on content produced by centos-art.sh +# script. # -# As far as I understand, the copyright exists to make people create -# more. The copyright gives creators the legal power over their -# creations and so the freedom to distribute them under the ethical -# terms the creator considers better. At this moment I don't feel -# very confident about this legal affairs and their legal -# implications, but I need to decide what copyright information the -# centos-art.sh script will print out when it be requested about it. -# So, in that sake, I'll assume the same copyright information used by -# The CentOS Wiki (http://wiki.centos.org/) as reference. +# As far as I understand, the copyright exists to make people create +# more. The copyright gives creators the legal power over their +# creations and so the freedom to distribute them under the ethical +# terms the creator considers better. At this moment I don't feel +# very confident about this legal affairs and their legal +# implications, but I need to decide what copyright information the +# centos-art.sh script will print out when it be requested about it. +# So, in that sake, I'll assume the same copyright information used +# by The CentOS Wiki (http://wiki.centos.org/) as reference. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -30,13 +35,11 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_printCopyrightInfo { - case "$1" in + case "${1}" in --license ) @@ -85,7 +88,7 @@ function cli_printCopyrightInfo { local FULL_YEAR=$(\ while [[ ${FIRST_YEAR} -le ${LAST_YEAR} ]];do echo -n "${FIRST_YEAR}, " - FIRST_YEAR=$(($FIRST_YEAR + 1)) + FIRST_YEAR=$((${FIRST_YEAR} + 1)) done) # Prepare full copyright year string and print it out. diff --git a/Automation/centos-art.sh-mods/Cli/cli_printMailingList.sh b/Automation/centos-art.sh-mods/Cli/cli_printMailingList.sh index b6053d7..f0f7c8d 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_printMailingList.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_printMailingList.sh @@ -1,8 +1,13 @@ #!/bin/bash +###################################################################### # -# cli_printMailingList.sh -- This function standardize the way mailing -# list addresses are printed on content produced by centos-art.sh -# script. +# cli_printMailingList.sh -- This function standardizes the way +# mailing list addresses are printed on content produced by +# centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -20,9 +25,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_printMailingList { @@ -37,20 +40,19 @@ function cli_printMailingList { # Initialize arguments with an empty value and set it as local # variable to this function scope. Doing this is very important to # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS for getopt. - cli_parseArgumentsReDef "$@" + local CLI_FUNCTION_ARGUMENTS='' - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" + # Redefine positional parameters using CLI_FUNCTION_ARGUMENTS variable. + eval set -- "${CLI_FUNCTION_ARGUMENTS}" # Look for options passed through command-line. while true; do - case "$1" in + case "${1}" in --docs ) MAILADDRS="${TCAR_BRAND}-docs@$(cli_printUrl --domain)" @@ -71,6 +73,6 @@ function cli_printMailingList { done # Print mail address. - echo "$MAILADDRS" + echo "${MAILADDRS}" } diff --git a/Automation/centos-art.sh-mods/Cli/cli_printMessage.sh b/Automation/centos-art.sh-mods/Cli/cli_printMessage.sh index e4cdd4d..e50796d 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_printMessage.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_printMessage.sh @@ -1,7 +1,12 @@ #!/bin/bash +###################################################################### # -# cli_printMessage.sh -- This function standardizes the way messages -# are printed by centos-art.sh script. +# cli_printMessage.sh -- This function standardizes the way messages +# are printed by centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -19,17 +24,15 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_printMessage { - local MESSAGE="$1" - local FORMAT="$2" + local MESSAGE="${1}" + local FORMAT="${2}" # Verify message variable, it cannot have an empty value. - if [[ $MESSAGE == '' ]];then + if [[ -z ${MESSAGE} ]];then cli_printMessage "`gettext "The message cannot be empty."`" --as-error-line fi @@ -39,11 +42,11 @@ function cli_printMessage { local MESSAGE_WIDTH=66 # Remove empty spaces from message. - MESSAGE=$(echo $MESSAGE | sed -r -e 's!^[[:space:]]+!!') + MESSAGE=$(echo ${MESSAGE} | sed -r -e 's!^[[:space:]]+!!') # Print messages that will always be printed no matter what value - # the FLAG_QUIET variable has. - case "$FORMAT" in + # the TCAR_FLAG_QUIET variable has. + case "${FORMAT}" in --as-stdout-line ) @@ -52,11 +55,11 @@ function cli_printMessage { # convenience, we transform absolute paths into relative # paths in order to free horizontal space on final output # messages. - echo "$MESSAGE" | sed -r \ - -e "s!${TCAR_WORKDIR}/!!g" \ + echo "${MESSAGE}" | sed -r \ + -e "s!${TCAR_USER_WRKDIR}/!!g" \ -e "s!> /!> !g" \ -e "s!/{2,}!/!g" \ - | awk 'BEGIN { FS=": " } + | gawk 'BEGIN { FS=": " } { if ( $0 ~ /^-+$/ ) print $0 @@ -68,15 +71,9 @@ function cli_printMessage { --as-error-line ) - # Define where the error was originated inside the - # centos-art.sh script. Print out the function name and - # line from the caller. - local ORIGIN="$(caller 1 | gawk '{ print $2 " L." $1 }')" - # Build the error message. - cli_printMessage "${CLI_NAME} (${ORIGIN}):" --as-stdout-line - cli_printMessage "${MESSAGE}" --as-response-line - cli_printMessage "${CLI_FUNCNAME}" --as-toknowmore-line + cli_printMessage "${TCAR_CLI_COMMAND} ($(cli_printCaller 2)): ${MESSAGE}" --as-stderr-line + cli_printMessage "$(cli_printCaller "2" "--name")" --as-toknowmore-line # Finish script execution with exit status 1 (SIGHUP) to # imply the script finished because an error. We are @@ -87,17 +84,11 @@ function cli_printMessage { --as-suggestion-line ) - # Define where the error was originated inside the - # centos-art.sh script. Print out the function name and - # line from the caller. - local ORIGIN="$(caller 1 | gawk '{ print $2 " L." $1 }')" - # Build the error message. - cli_printMessage "${CLI_NAME} (${ORIGIN}):" --as-stdout-line - cli_printMessage "`gettext "The path provided cannot be processed the way you entered it."`" --as-stdout-line - cli_printMessage "`gettext "Instead, try the following equivalence:"`" --as-stdout-line - cli_printMessage "${MESSAGE}" --as-response-line - cli_printMessage "${CLI_FUNCNAME}" --as-toknowmore-line + cli_printMessage "${TACAR_CLI_COMMAND} ($(cli_printCaller 2)):" --as-stderr-line + cli_printMessage "`gettext "The path provided cannot be processed the way you entered it."`" --as-stderr-line + cli_printMessage "`gettext "Instead, try the following equivalence:"` ${MESSAGE}" --as-stderr-line + cli_printMessage "${CLI_FUNCTION_NAME}" --as-toknowmore-line # Finish script execution with exit status 1 (SIGHUP) to # imply the script finished because an error. We are @@ -107,9 +98,7 @@ function cli_printMessage { ;; --as-toknowmore-line ) - cli_printMessage '-' --as-separator-line - cli_printMessage "`gettext "To know more, run"` ${CLI_NAME} ${MESSAGE} --help" --as-stdout-line - cli_printMessage '-' --as-separator-line + cli_printMessage "`gettext "To know more, run"` ${TCAR_CLI_COMMAND} help --id=${MESSAGE} " --as-stderr-line ;; --as-yesornorequest-line ) @@ -123,14 +112,14 @@ function cli_printMessage { # Define default answer. local ANSWER=${N} - if [[ $FLAG_ANSWER == 'true' ]];then + if [[ ${TCAR_FLAG_YES} == 'true' ]];then ANSWER=${Y} else # Print the question to standard error. - cli_printMessage "$MESSAGE [${Y}/${N}]" --as-request-line + cli_printMessage "${MESSAGE} [${Y}/${N}]" --as-request-line # Redefine default answer based on user's input. read ANSWER @@ -150,13 +139,13 @@ function cli_printMessage { # Create selection based on message. local NAME='' select NAME in ${MESSAGE};do - echo $NAME + echo ${NAME} break done ;; --as-response-line ) - cli_printMessage "--> $MESSAGE" --as-stdout-line + cli_printMessage "--> ${MESSAGE}" --as-stderr-line ;; --as-request-line ) @@ -165,119 +154,119 @@ function cli_printMessage { --as-notrailingnew-line ) echo -e -n "${MESSAGE}" | sed -r \ - -e "s!${TCAR_WORKDIR}/!!g" + -e "s!${TCAR_USER_WRKDIR}/!!g" 1>&2 ;; --as-stderr-line ) - echo "$MESSAGE" | sed -r \ - -e "s!${TCAR_WORKDIR}/!!g" 1>&2 + echo "${MESSAGE}" | sed -r \ + -e "s!${TCAR_USER_WRKDIR}/!!g" 1>&2 ;; esac # Verify verbose option. The verbose option controls whether # messages are printed or not. - if [[ "$FLAG_QUIET" == 'true' ]];then + if [[ "${TCAR_FLAG_QUIET}" == 'true' ]];then return fi - # Print messages that will be printed only when the FLAG_QUIET + # Print messages that will be printed only when the TCAR_FLAG_QUIET # variable is provided to centos-art.sh script. - case "$FORMAT" in + case "${FORMAT}" in --as-separator-line ) # Build the separator line. MESSAGE=$(\ - until [[ $MESSAGE_WIDTH -eq 0 ]];do - echo -n "$(echo $MESSAGE | sed -r 's!(.).*!\1!')" - MESSAGE_WIDTH=$(($MESSAGE_WIDTH - 1)) + until [[ ${MESSAGE_WIDTH} -eq 0 ]];do + echo -n "$(echo ${MESSAGE} | sed -r 's!(.).*!\1!')" + MESSAGE_WIDTH=$((${MESSAGE_WIDTH} - 1)) done) # Draw the separator line. - echo "$MESSAGE" + echo "${MESSAGE}" ;; --as-banner-line ) cli_printMessage '-' --as-separator-line - cli_printMessage "$MESSAGE" --as-stdout-line + cli_printMessage "${MESSAGE}" --as-stdout-line cli_printMessage '-' --as-separator-line ;; --as-processing-line ) - cli_printMessage "`gettext "Processing"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Processing"`: ${MESSAGE}" --as-stdout-line ;; --as-cropping-line ) - cli_printMessage "`gettext "Cropping from"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Cropping from"`: ${MESSAGE}" --as-stdout-line ;; --as-tuningup-line ) - cli_printMessage "`gettext "Tuning-up"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Tuning-up"`: ${MESSAGE}" --as-stdout-line ;; --as-checking-line ) - cli_printMessage "`gettext "Checking"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Checking"`: ${MESSAGE}" --as-stdout-line ;; --as-combining-line ) - cli_printMessage "`gettext "Combining"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Combining"`: ${MESSAGE}" --as-stdout-line ;; --as-creating-line | --as-updating-line ) - if [[ -a "$MESSAGE" ]];then - cli_printMessage "`gettext "Updating"`: $MESSAGE" --as-stdout-line + if [[ -a "${MESSAGE}" ]];then + cli_printMessage "`gettext "Updating"`: ${MESSAGE}" --as-stdout-line else - cli_printMessage "`gettext "Creating"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Creating"`: ${MESSAGE}" --as-stdout-line fi ;; --as-deleting-line ) - cli_printMessage "`gettext "Deleting"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Deleting"`: ${MESSAGE}" --as-stdout-line ;; --as-reading-line ) - cli_printMessage "`gettext "Reading"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Reading"`: ${MESSAGE}" --as-stdout-line ;; --as-savedas-line ) - cli_printMessage "`gettext "Saved as"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Saved as"`: ${MESSAGE}" --as-stdout-line ;; --as-linkto-line ) - cli_printMessage "`gettext "Linked to"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Linked to"`: ${MESSAGE}" --as-stdout-line ;; --as-movedto-line ) - cli_printMessage "`gettext "Moved to"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Moved to"`: ${MESSAGE}" --as-stdout-line ;; --as-translation-line ) - cli_printMessage "`gettext "Translation"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Translation"`: ${MESSAGE}" --as-stdout-line ;; --as-translating-line ) - cli_printMessage "`gettext "Translating"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Translating"`: ${MESSAGE}" --as-stdout-line ;; --as-validating-line ) - cli_printMessage "`gettext "Validating"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Validating"`: ${MESSAGE}" --as-stdout-line ;; --as-template-line ) - cli_printMessage "`gettext "Template"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Template"`: ${MESSAGE}" --as-stdout-line ;; --as-configuration-line ) - cli_printMessage "`gettext "Configuration"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Configuration"`: ${MESSAGE}" --as-stdout-line ;; --as-palette-line ) - cli_printMessage "`gettext "Palette"`: $MESSAGE" --as-stdout-line + cli_printMessage "`gettext "Palette"`: ${MESSAGE}" --as-stdout-line ;; --as-inkscape-line ) - cli_printMessage "$MESSAGE" --as-stdout-line + cli_printMessage "${MESSAGE}" --as-stdout-line ;; esac diff --git a/Automation/centos-art.sh-mods/Cli/cli_printUrl.sh b/Automation/centos-art.sh-mods/Cli/cli_printUrl.sh index 2a6ce80..64f6649 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_printUrl.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_printUrl.sh @@ -1,9 +1,14 @@ #!/bin/bash +###################################################################### # -# cli_printUrl.sh -- This function standardizes the way URLs are -# printed by centos-art.sh script. This function describes the -# domain organization of The CentOS Project through its URLs and -# provides a way to print them out when needed. +# cli_printUrl.sh -- This function standardizes the way URLs are +# printed by centos-art.sh script. This function describes the +# domain organization of The CentOS Project through its URLs and +# provides a way to print them out when needed. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,9 +26,7 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_printUrl { @@ -38,20 +41,19 @@ function cli_printUrl { # Initialize arguments with an empty value and set it as local # variable to this function scope. Doing this is very important to # avoid any clash with higher execution environments. - local ARGUMENTS='' - - # Prepare ARGUMENTS for getopt. - cli_parseArgumentsReDef "$@" + local CLI_FUNCTION_ARGUMENTS='' - # Redefine ARGUMENTS using getopt(1) command parser. - cli_parseArguments + # Process all arguments currently available in this function + # environment. If either ARGSS or ARGSL local variables have been + # defined, argument processing goes through getopt for validation. + cli_setArguments "${@}" - # Redefine positional parameters using ARGUMENTS variable. - eval set -- "$ARGUMENTS" + # Redefine positional parameters using CLI_FUNCTION_ARGUMENTS variable. + eval set -- "${CLI_FUNCTION_ARGUMENTS}" # Look for options passed through command-line. while true; do - case "$1" in + case "${1}" in --domain ) URL="${TCAR_BRAND}.org" @@ -131,7 +133,7 @@ function cli_printUrl { ;; --as-html-link ) - URL="${URL}" + URL="${URL}" shift 1 ;; @@ -144,6 +146,6 @@ function cli_printUrl { done # Print Url. - echo "$URL" + echo "${URL}" } diff --git a/Automation/centos-art.sh-mods/Cli/cli_runFnEnvironment.sh b/Automation/centos-art.sh-mods/Cli/cli_runFnEnvironment.sh index 5b9641d..a54f554 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_runFnEnvironment.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_runFnEnvironment.sh @@ -1,9 +1,14 @@ #!/bin/bash +###################################################################### # -# cli_runFnEnvironment.sh -- This function standardizes the way -# centos-art.sh script is called to itself. The main purpose of this -# somehow own interface is to control the parent script flow based on -# specific function environments exit status. +# cli_runFnEnvironment.sh -- This function standardizes the way +# centos-art.sh script is called to itself. The main purpose of this +# somehow own interface is to control the parent script flow based +# on specific function environments exit status. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,14 +26,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_runFnEnvironment { # Execute specific function environment. - ${CLI_NAME} $@ + ${CLI_NAME} ${@} # Retrieve exit status. local STATUS=$? diff --git a/Automation/centos-art.sh-mods/Cli/cli_setArguments.sh b/Automation/centos-art.sh-mods/Cli/cli_setArguments.sh new file mode 100755 index 0000000..6fc8956 --- /dev/null +++ b/Automation/centos-art.sh-mods/Cli/cli_setArguments.sh @@ -0,0 +1,91 @@ +#!/bin/bash +###################################################################### +# +# cli_setArguments.sh -- This function uses getopt to process +# arguments passed to centos-art.sh script. +# +# This function works with the following three variables: +# +# ARGSS +# Stores getopt short arguments definition. +# +# ARGSL +# Stores getopt long arguments definition. +# +# CLI_FUNCTION_ARGUMENTS +# Stores arguments passed to functions or command-line +# interface depending the context it is defined. +# +# These three variables are not defined in this function but the +# function environment you want to provide option parsing for, +# through getopt command. Using local definition for these three +# variables let you to nest option parsing inside different +# function-environment levels. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 +# +# Copyright (C) 2009-2013 The CentOS Project +# +# 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 +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# +###################################################################### + +function cli_setArguments { + + # Verify existence of arguments that will be processed. If there + # is none, return to caller. + if [[ -z "${@}" ]];then + return + fi + + local ARGUMENT='' + + # Fill up arguments global variable with current positional + # parameter information. To avoid interpretation problems, use + # single quotes to enclose each argument (CLI_FUNCTION_ARGUMENTS) from + # command-line individually. + for ARGUMENT in "${@}"; do + + # Remove any single quote from arguments passed to + # centos-art.sh script. We will use single quotes for grouping + # option values so white space can be passed through them. + ARGUMENT=$(echo "${ARGUMENT}" | tr -d "'") + + # Concatenate arguments and enclose them to let getopt to + # process them when they have spaces inside. + CLI_FUNCTION_ARGUMENTS="${CLI_FUNCTION_ARGUMENTS} '${ARGUMENT}'" + + done + + # Verify non-option arguments passed to command-line. If there + # isn't any or dot is provided, redefine the CLI_FUNCTION_ARGUMENTS variable to + # use the current location the centos-art.sh script was called + # from. + if [[ -z "${CLI_FUNCTION_ARGUMENTS}" ]];then + CLI_FUNCTION_ARGUMENTS=${PWD} + fi + + # Redefine positional parameters using CLI_FUNCTION_ARGUMENTS variable. + if [[ ! -z ${ARGSS} ]] || [[ ! -z ${ARGSL} ]];then + eval set -- "${CLI_FUNCTION_ARGUMENTS}" + CLI_FUNCTION_ARGUMENTS=$(getopt -o "${ARGSS}" -l "${ARGSL}" \ + -n "${TCAR_CLI_COMMAND} ($(cli_printCaller 2))" -- "${@}") + if [[ $? -ne 0 ]];then + cli_printMessage "`gettext "The argument verification failed."`" --as-error-line + fi + fi + +} diff --git a/Automation/centos-art.sh-mods/Cli/cli_synchronizeRepoChanges.sh b/Automation/centos-art.sh-mods/Cli/cli_synchronizeRepoChanges.sh index 5bfb877..0f04ad3 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_synchronizeRepoChanges.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_synchronizeRepoChanges.sh @@ -1,9 +1,14 @@ #!/bin/bash +###################################################################### # -# cli_synchronizeRepoChanges.sh -- This function standardizes the way -# changes are synchronized between the working copy and the central -# repository. This function is an interface to the Svn functionality -# of the centos-art.sh script. +# cli_synchronizeRepoChanges.sh -- This function standardizes the +# way changes are synchronized between the working copy and the +# central repository. This function is an interface to the Svn +# functionality of the centos-art.sh script. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -21,21 +26,19 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_synchronizeRepoChanges { # Verify synchronization flag. - if [[ ! $FLAG_SYNCHRONIZE == 'true' ]];then + if [[ ${FLAG_SYNCHRONIZE} != 'true' ]];then return fi # Verify existence of locations passed to this function. - cli_checkFiles -e $@ + cli_checkFiles -e ${@} # Synchronize changes. - cli_runFnEnvironment vcs --synchronize $@ + cli_runFnEnvironment vcs --synchronize ${@} } diff --git a/Automation/centos-art.sh-mods/Cli/cli_terminateScriptExecution.sh b/Automation/centos-art.sh-mods/Cli/cli_terminateScriptExecution.sh index cf855ed..09b1d20 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_terminateScriptExecution.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_terminateScriptExecution.sh @@ -1,10 +1,15 @@ #!/bin/bash +###################################################################### # -# cli_terminateScriptExecution.sh -- This function standardizes the -# actions that must be realized just before leaving the script -# execution (e.g., cleaning temporal files). This function is the one -# called when interruption signals like EXIT, SIGHUP, SIGINT and -# SIGTERM are detected. +# cli_terminateScriptExecution.sh -- This function standardizes the +# actions that must be realized just before leaving the script +# execution (e.g., cleaning temporal files). This function is the +# one called when interruption signals like EXIT, SIGHUP, SIGINT and +# SIGTERM are detected. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -22,14 +27,12 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_terminateScriptExecution { # Remove temporal directory. - rm -r ${TMPDIR} + rm -r ${TCAR_CLI_TEMPDIR} # NOTE: Don't specify an exit status here. As convenction we do # this when error messages are triggerd. See `--as-error-line' diff --git a/Automation/centos-art.sh-mods/Cli/cli_unsetFunctions.sh b/Automation/centos-art.sh-mods/Cli/cli_unsetFunctions.sh index 8a31dff..d1346d7 100755 --- a/Automation/centos-art.sh-mods/Cli/cli_unsetFunctions.sh +++ b/Automation/centos-art.sh-mods/Cli/cli_unsetFunctions.sh @@ -1,7 +1,12 @@ #!/bin/bash +###################################################################### # -# cli_unsetFunctions.sh -- This function unsets functionalities from -# `centos-art.sh' script execution environment. +# cli_unsetFunctions.sh -- This function unsets functionalities from +# centos-art.sh script execution environment. +# +# Written by: +# * Alain Reguera Delgado , 2009-2013 +# Key fingerprint = D67D 0F82 4CBD 90BC 6421 DF28 7CCE 757C 17CA 3951 # # Copyright (C) 2009-2013 The CentOS Project # @@ -19,21 +24,17 @@ # along with this program; if not, write to the Free Software # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. # -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- +###################################################################### function cli_unsetFunctions { - # Define export id used to retrive function files. This is the + # Define export id used to retrieve function files. This is the # same export id used to export functions without the directory # part. - local EXPORTID=$(basename "$1") + local FUNCTION_EXPORTID=$(basename "${1}") - # Verify suffix value used to retrive function files. Assuming no - # suffix value is passed as second argument to this function, use - # the function name value (CLI_FUNCNAME) as default value. - if [[ $EXPORTID == '' ]];then + # Verify suffix value used to retrieve function files. + if [[ ${FUNCTION_EXPORTID} == '' ]];then cli_printMessage "`gettext "The export id was not provided."`" --as-error-line fi @@ -41,12 +42,12 @@ function cli_unsetFunctions { # list of function definitions previously exported by # `cli_exportFunctions'. Be sure to limit the list to function # names that start with the suffix specified only. - local FUNCDEF='' - local FUNCDEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${EXPORTID}") + local FUNCTION_DEF='' + local FUNCTION_DEFS=$(declare -F | gawk '{ print $3 }' | egrep "^${FUNCTION_EXPORTID}") # Unset function names from current execution environment. - for FUNCDEF in $FUNCDEFS;do - unset -f $FUNCDEF + for FUNCTION_DEF in ${FUNCTION_DEFS};do + unset -f ${FUNCTION_DEF} done }