From 0647ebd9717d5aec5d38425bdaa854b26cd43721 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Jan 15 2014 21:03:02 +0000 Subject: Update tcar_setModuleArguments function. - Previously, tcar_setModuleArguments verified and initialized TCAR_MODULE_ARGUMENT variables before processing them. This isn't necessary because the script flow never reaches this point when the TCAR_MODULE_ARGUMENT is empty or contains one or more spaces as value. In such cases the _printUsage function is called and the script execution cut once the usage information has been printed out. This update changes the tcar_setModuleArguments function to remove the TCAR_MODULE_ARGUMENTS verification and initialization from it. --- diff --git a/Scripts/tcar_setModuleArguments.sh b/Scripts/tcar_setModuleArguments.sh index dd88f61..b537123 100755 --- a/Scripts/tcar_setModuleArguments.sh +++ b/Scripts/tcar_setModuleArguments.sh @@ -43,32 +43,24 @@ # levels. function tcar_setModuleArguments { - # Verify non-option arguments passed to command-line. If there - # isn't any or dot is provided, redefine the TCAR_MODULE_ARGUMENT - # variable to use the current location the tcar.sh script - # was called from. - if [[ -z "${TCAR_MODULE_ARGUMENT}" ]];then - TCAR_MODULE_ARGUMENT=${PWD} - fi - # Verify presence of either short or long options in the - # environment. If they are present apply option validation through - # getopt. - if [[ ! -z ${ARGSS} ]] || [[ ! -z ${ARGSL} ]];then - - # Redefine positional parameters using TCAR_MODULE_ARGUMENT variable. - eval set -- "${TCAR_MODULE_ARGUMENT}" + # environment. There is not anything to do here if they both are + # empty. + if [[ -z ${ARGSS} && -z ${ARGSL} ]];then + return + fi - # Process positional parameters using getopt's option validation. - TCAR_MODULE_ARGUMENT=$(getopt -o "${ARGSS}" -l "${ARGSL}" \ - -n "${TCAR_SCRIPT_NAME} (${TCAR_MODULE_NAME})" -- "${@}") + # Redefine positional parameters using TCAR_MODULE_ARGUMENT variable. + eval set -- "${TCAR_MODULE_ARGUMENT}" - # Verify getopt's exit status and finish the script execution - # with an error message, if it failed. - if [[ $? -ne 0 ]];then - tcar_printMessage "`gettext "The argument verification failed."`" --as-error-line - fi + # Process positional parameters using getopt's option validation. + TCAR_MODULE_ARGUMENT=$(getopt -o "${ARGSS}" -l "${ARGSL}" \ + -n "${TCAR_SCRIPT_NAME} (${TCAR_MODULE_NAME})" -- "${@}") + # Verify getopt's exit status and finish the script execution with + # an error message, if it failed. + if [[ $? -ne 0 ]];then + tcar_printMessage "`gettext "The argument verification failed."`" --as-error-line fi }