From daf41a4eb78bd6f8adf863836ec9b96f28879702 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Oct 07 2013 01:24:08 +0000 Subject: Update tcar_printHelp file. - Previously, the tcar_printHelp function failed to print script documentation. The condition set when tcar_printHelp message is called from centos-art.sh script isn't retrieving the correct documentation name. This update changes the tcar_printHelp.sh file to retrieve the correct documentation file when tcar_printHelp is called from centos-art.sh script and there isn't any module name defined yet. --- diff --git a/Automation/Scripts/tcar_printHelp.sh b/Automation/Scripts/tcar_printHelp.sh index b243ec7..d4020ea 100755 --- a/Automation/Scripts/tcar_printHelp.sh +++ b/Automation/Scripts/tcar_printHelp.sh @@ -32,19 +32,18 @@ function tcar_printHelp { # module name is used. local TCAR_MANPAGE_NAME="${1:-${TCAR_MODULE_NAME}}" - # When the tcar_printHelp function is called from centos-art.sh file, the - # module name is set to an empty value so we assume you are retrieving - # documentation for centos-art.sh script itself. - if [[ -z ${TCAR_MANPAGE_NAME} ]];then - TCAR_MANPAGE_NAME=${TCAR_SCRIPT_NAME} - fi - - # When the tcar_printHelp function is called from centos-art.sh file and - # an argument is passed to tcar_printHelp function, the argument comes - # here without stripping out the option's value so need to remove it here - # in order to request the correct information (that after the equal sign). - if [[ ${TCAR_MANPAGE_NAME} =~ '^--help' ]];then - TCAR_MANPAGE_NAME=$(echo ${TCAR_MANPAGE_NAME} | cut -d'=' -f2) + # When the module name has not been set and the tcar_printHelp + # function is called from centos-art.sh file, the page name come + # with with --help as opening string and probably as + # --help=filename.sh. In the first case it prints the script + # documentation. In the second case it prints documentation for + # the file specified. + if [[ -z ${TCAR_MODULE_NAME} ]];then + if [[ ${TCAR_MANPAGE_NAME} =~ '^--help=[[:alnum:]_-.]+' ]];then + TCAR_MANPAGE_NAME=$(echo ${TCAR_MANPAGE_NAME} | cut -d'=' -f2) + else + TCAR_MANPAGE_NAME=${TCAR_SCRIPT_NAME} + fi fi # Print requested documentation.