From 793c4c11d1cf37f2280cf1650e989ea8d889e523 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: May 22 2011 00:42:27 +0000 Subject: Rename cli_doParseArguments to cli_parseArguments. --- diff --git a/Scripts/Functions/Copy/copy_getOptions.sh b/Scripts/Functions/Copy/copy_getOptions.sh index 526389d..7f88c73 100755 --- a/Scripts/Functions/Copy/copy_getOptions.sh +++ b/Scripts/Functions/Copy/copy_getOptions.sh @@ -32,7 +32,7 @@ function copy_getOptions { local ARGSL="quiet,answer-yes,dont-commit-changes" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" @@ -75,6 +75,6 @@ function copy_getOptions { done # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" } diff --git a/Scripts/Functions/Help/help_getOptions.sh b/Scripts/Functions/Help/help_getOptions.sh index aaea5c2..466e249 100755 --- a/Scripts/Functions/Help/help_getOptions.sh +++ b/Scripts/Functions/Help/help_getOptions.sh @@ -32,7 +32,7 @@ function help_getOptions { local ARGSL="quiet,answer-yes,dont-commit-changes,read,search:,edit,update,copy,delete,rename" # Parse arguments using getopt(1) command parser. - cli_doParseArguments + cli_parseArguments # Reset positional parameters using output from (getopt) argument # parser. @@ -120,6 +120,6 @@ function help_getOptions { done # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" } diff --git a/Scripts/Functions/Locale/locale_getOptions.sh b/Scripts/Functions/Locale/locale_getOptions.sh index 8304f30..f09a07d 100644 --- a/Scripts/Functions/Locale/locale_getOptions.sh +++ b/Scripts/Functions/Locale/locale_getOptions.sh @@ -32,7 +32,7 @@ function locale_getOptions { local ARGSL="filter:,quiet,answer-yes,dont-commit-changes,update,edit,dont-create-mo" # Parse arguments using getopt(1) command parser. - cli_doParseArguments + cli_parseArguments # Reset positional parameters using output from (getopt) argument # parser. @@ -95,6 +95,6 @@ function locale_getOptions { done # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" } diff --git a/Scripts/Functions/Prepare/prepare_getOptions.sh b/Scripts/Functions/Prepare/prepare_getOptions.sh index 46f1ffe..32b0ef9 100755 --- a/Scripts/Functions/Prepare/prepare_getOptions.sh +++ b/Scripts/Functions/Prepare/prepare_getOptions.sh @@ -32,7 +32,7 @@ function prepare_getOptions { local ARGSL="quiet,answer-yes,packages,links,environment" # Parse arguments using getopt(1) command parser. - cli_doParseArguments + cli_parseArguments # Reset positional parameters using output from (getopt) argument # parser. diff --git a/Scripts/Functions/Render/render_getConfigOption.sh b/Scripts/Functions/Render/render_getConfigOption.sh index b5c363e..c79d864 100755 --- a/Scripts/Functions/Render/render_getConfigOption.sh +++ b/Scripts/Functions/Render/render_getConfigOption.sh @@ -62,7 +62,7 @@ function render_getConfigOption { # built-in commands here. Use the `cli_printMessage' functionality # instead. This is required in order to reverse the apostrophe # codification accomplished when options were retrived from - # command-line (cli_doParseArgumentsReDef) in the argument of + # command-line (cli_parseArgumentsReDef) in the argument of # options like `--post-rendition' and `--last-rendition'. if [[ $OPTION != '' ]];then cli_printMessage "$OPTION" --as-stdout-line diff --git a/Scripts/Functions/Render/render_getOptions.sh b/Scripts/Functions/Render/render_getOptions.sh index 2902661..99aff42 100644 --- a/Scripts/Functions/Render/render_getOptions.sh +++ b/Scripts/Functions/Render/render_getOptions.sh @@ -32,7 +32,7 @@ function render_getOptions { local ARGSL="filter:,quiet,answer-yes,dont-commit-changes,dont-dirspecific,releasever:,basearch:,post-rendition:,last-rendition:,theme-model:" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" @@ -116,6 +116,6 @@ function render_getOptions { done # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" } diff --git a/Scripts/Functions/Tuneup/tuneup_getOptions.sh b/Scripts/Functions/Tuneup/tuneup_getOptions.sh index 1adf1fa..c6c623d 100755 --- a/Scripts/Functions/Tuneup/tuneup_getOptions.sh +++ b/Scripts/Functions/Tuneup/tuneup_getOptions.sh @@ -32,7 +32,7 @@ function tuneup_getOptions { local ARGSL="filter:,quiet,answer-yes,dont-commit-changes" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" @@ -80,6 +80,6 @@ function tuneup_getOptions { done # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" } diff --git a/Scripts/Functions/cli.sh b/Scripts/Functions/cli.sh index ec33c31..9c8e44e 100644 --- a/Scripts/Functions/cli.sh +++ b/Scripts/Functions/cli.sh @@ -59,7 +59,7 @@ function cli { local FLAG_DONT_COMMIT_CHANGES='false' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Define function directory (FUNCDIR). The directory path where # functionalities are stored inside the repository. @@ -99,7 +99,7 @@ function cli { shift 1 # Redefine ARGUMENTS using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Define default text editors used by centos-art.sh script. if [[ ! "$EDITOR" =~ '/usr/bin/(vim|emacs|nano)' ]];then diff --git a/Scripts/Functions/cli_checkFiles.sh b/Scripts/Functions/cli_checkFiles.sh index 2c0db1e..699899b 100644 --- a/Scripts/Functions/cli_checkFiles.sh +++ b/Scripts/Functions/cli_checkFiles.sh @@ -66,10 +66,10 @@ function cli_checkFiles { local FILE='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_checkPathComponent.sh b/Scripts/Functions/cli_checkPathComponent.sh index d0f0c70..44aaf08 100755 --- a/Scripts/Functions/cli_checkPathComponent.sh +++ b/Scripts/Functions/cli_checkPathComponent.sh @@ -41,10 +41,10 @@ function cli_checkPathComponent { local FILE='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_doParseArguments.sh b/Scripts/Functions/cli_doParseArguments.sh deleted file mode 100755 index c78ac48..0000000 --- a/Scripts/Functions/cli_doParseArguments.sh +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/bash -# -# cli_doParseArguments.sh -- This function redefines arguments -# (ARGUMENTS) global variable using getopt(1) output. -# -# Copyright (C) 2009, 2010, 2011 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. -# -# ---------------------------------------------------------------------- -# $Id$ -# ---------------------------------------------------------------------- - -function cli_doParseArguments { - - # Reset positional parameters using optional arguments. - eval set -- "$ARGUMENTS" - - # Parse optional arguments using getopt. - ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n "$CLI_PROGRAM (${FUNCNAME[1]})" -- "$@") - - # Be sure getout parsed arguments successfully. - if [[ $? != 0 ]]; then - cli_printMessage "${FUNCDIRNAM}" --as-toknowmore-line - fi - -} diff --git a/Scripts/Functions/cli_doParseArgumentsReDef.sh b/Scripts/Functions/cli_doParseArgumentsReDef.sh index b6d9041..6a6c4c0 100755 --- a/Scripts/Functions/cli_doParseArgumentsReDef.sh +++ b/Scripts/Functions/cli_doParseArgumentsReDef.sh @@ -1,6 +1,6 @@ #!/bin/bash # -# cli_doParseArgumentsReDef.sh -- This function initiates/reset and +# cli_parseArgumentsReDef.sh -- This function initiates/reset and # sanitates positional parameters passed to this function and creates # the the list of arguments that getopt will process. # @@ -24,7 +24,7 @@ # $Id$ # ---------------------------------------------------------------------- -function cli_doParseArgumentsReDef { +function cli_parseArgumentsReDef { local ARG diff --git a/Scripts/Functions/cli_getFilesList.sh b/Scripts/Functions/cli_getFilesList.sh index dcf13cb..003bebd 100755 --- a/Scripts/Functions/cli_getFilesList.sh +++ b/Scripts/Functions/cli_getFilesList.sh @@ -42,10 +42,10 @@ function cli_getFilesList { local OPTIONS='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_getPathComponent.sh b/Scripts/Functions/cli_getPathComponent.sh index 702f03a..a1f065d 100755 --- a/Scripts/Functions/cli_getPathComponent.sh +++ b/Scripts/Functions/cli_getPathComponent.sh @@ -50,10 +50,10 @@ function cli_getPathComponent { local THEME="Identity/Images/Themes/(([A-Za-z0-9]+)/(${RELEASE}))/" # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_getRepoName.sh b/Scripts/Functions/cli_getRepoName.sh index ba4c0c9..ae1be96 100755 --- a/Scripts/Functions/cli_getRepoName.sh +++ b/Scripts/Functions/cli_getRepoName.sh @@ -40,10 +40,10 @@ function cli_getRepoName { local ARGUMENTS='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_getRepoTLDir.sh b/Scripts/Functions/cli_getRepoTLDir.sh index 5c8735a..d8ac11f 100755 --- a/Scripts/Functions/cli_getRepoTLDir.sh +++ b/Scripts/Functions/cli_getRepoTLDir.sh @@ -42,10 +42,10 @@ function cli_getRepoTLDir { local REPLACE='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_parseArguments.sh b/Scripts/Functions/cli_parseArguments.sh new file mode 100755 index 0000000..6e006c7 --- /dev/null +++ b/Scripts/Functions/cli_parseArguments.sh @@ -0,0 +1,39 @@ +#!/bin/bash +# +# cli_parseArguments.sh -- This function redefines arguments +# (ARGUMENTS) global variable using getopt(1) output. +# +# Copyright (C) 2009, 2010, 2011 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. +# +# ---------------------------------------------------------------------- +# $Id$ +# ---------------------------------------------------------------------- + +function cli_parseArguments { + + # Reset positional parameters using optional arguments. + eval set -- "$ARGUMENTS" + + # Parse optional arguments using getopt. + ARGUMENTS=$(getopt -o "$ARGSS" -l "$ARGSL" -n "$CLI_PROGRAM (${FUNCNAME[1]})" -- "$@") + + # Be sure getout parsed arguments successfully. + if [[ $? != 0 ]]; then + cli_printMessage "${FUNCDIRNAM}" --as-toknowmore-line + fi + +} diff --git a/Scripts/Functions/cli_printActionPreamble.sh b/Scripts/Functions/cli_printActionPreamble.sh index 79d93c3..c8270bc 100755 --- a/Scripts/Functions/cli_printActionPreamble.sh +++ b/Scripts/Functions/cli_printActionPreamble.sh @@ -50,10 +50,10 @@ function cli_printActionPreamble { local FILE='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_printCopyrightInfo.sh b/Scripts/Functions/cli_printCopyrightInfo.sh index de2850c..02f8758 100755 --- a/Scripts/Functions/cli_printCopyrightInfo.sh +++ b/Scripts/Functions/cli_printCopyrightInfo.sh @@ -46,10 +46,10 @@ function cli_printCopyrightInfo { local ARGUMENTS='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS" diff --git a/Scripts/Functions/cli_printMessage.sh b/Scripts/Functions/cli_printMessage.sh index cb0d276..e131128 100755 --- a/Scripts/Functions/cli_printMessage.sh +++ b/Scripts/Functions/cli_printMessage.sh @@ -41,7 +41,7 @@ function cli_printMessage { # Reverse the codification performed on characters that may affect # parsing options and non-option arguments. This codification is # realized before building the ARGUMENTS variable, at - # cli_doParseArgumentsReDef, and we need to reverse it back here + # cli_parseArgumentsReDef, and we need to reverse it back here # in order to show the correct character when the message be # printed out on the screen. MESSAGE=$(echo $MESSAGE | sed -e "s/\\\0x27/'/g") diff --git a/Scripts/Functions/cli_printUrl.sh b/Scripts/Functions/cli_printUrl.sh index d65a55a..5994d8d 100755 --- a/Scripts/Functions/cli_printUrl.sh +++ b/Scripts/Functions/cli_printUrl.sh @@ -40,10 +40,10 @@ function cli_printUrl { local ARGUMENTS='' # Redefine ARGUMENTS variable using current positional parameters. - cli_doParseArgumentsReDef "$@" + cli_parseArgumentsReDef "$@" # Redefine ARGUMENTS variable using getopt output. - cli_doParseArguments + cli_parseArguments # Redefine positional parameters using ARGUMENTS variable. eval set -- "$ARGUMENTS"