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.