diff --git a/tcar-scripts/tcar.sh b/tcar-scripts/tcar.sh index 625d5df..050d2db 100755 --- a/tcar-scripts/tcar.sh +++ b/tcar-scripts/tcar.sh @@ -52,14 +52,14 @@ declare -xr TCAR_SCRIPT_TEMPDIR=$(mktemp -p /tmp -d ${TCAR_SCRIPT_NAME}-XXXXXX) declare -xr TCAR_SCRIPT_CONFIG=${HOME}/.tcar.conf # Base directory where man pages are searched at. -declare -x TCAR_SCRIPT_MANUALS=/usr/share/man +declare -xr TCAR_SCRIPT_MANUALS=/usr/share/man + +# Base directory where automation script modules are installed in. +declare -xr TCAR_SCRIPT_MODULES_BASEDIR=${TCAR_BASEDIR}/modules # Default text editor. declare -x TCAR_SCRIPT_EDITOR=/usr/bin/vim -# Base directory where automation script modules are installed in. -declare -x TCAR_SCRIPT_MODULES_BASEDIR=${TCAR_BASEDIR}/modules - ###################################################################### # Internationalization ###################################################################### diff --git a/tcar-scripts/tcar_getFilesList.sh b/tcar-scripts/tcar_getFilesList.sh index 3f43952..1a1fad9 100755 --- a/tcar-scripts/tcar_getFilesList.sh +++ b/tcar-scripts/tcar_getFilesList.sh @@ -29,66 +29,39 @@ function tcar_getFilesList { - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='pattern:,mindepth:,maxdepth:,type:,uid:' - # Initialize pattern used to reduce the find output. local PATTERN="${TCAR_FLAG_FILTER}" # Initialize options used with find command. local OPTIONS='' - # 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 TCAR_MODULE_ARGUMENT='' - - # 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. - tcar_setModuleArguments "${@}" - - # Redefine positional parameters using TCAR_MODULE_ARGUMENT variable. - eval set -- "${TCAR_MODULE_ARGUMENT}" + OPTIND=1 + while getopts "p:,a:,i:,t:,u:" OPTION "${@}"; do - while true;do - case "${1}" in - - --pattern ) - PATTERN="${2}" - shift 2 + case "${OPTION}" in + p ) + PATTERN="${OPTARG}" ;; - - --maxdepth ) - OPTIONS="${OPTIONS} -maxdepth ${2}" - shift 2 + a ) + OPTIONS="${OPTIONS} -maxdepth ${OPTARG}" ;; - - --mindepth ) - OPTIONS="${OPTIONS} -mindepth ${2}" - shift 2 + i ) + OPTIONS="${OPTIONS} -mindepth ${OPTARG}" ;; - - --type ) - OPTIONS="${OPTIONS} -type ${2}" - shift 2 - ;; - - --uid ) - OPTIONS="${OPTIONS} -uid ${2}" - shift 2 + t ) + OPTIONS="${OPTIONS} -type ${OPTARG}" ;; - - -- ) - shift 1 - break + u ) + OPTIONS="${OPTIONS} -uid ${OPTARG}" ;; esac + done + # Clean up positional parameters to reflect the fact that options + # have been processed already. + shift $(( ${OPTIND} - 1 )) + # At this point all options arguments have been processed and # removed from positional parameters. Only non-option arguments # remain so we use them as source location for find command to diff --git a/tcar-scripts/tcar_getPathComponent.sh b/tcar-scripts/tcar_getPathComponent.sh index d006768..a87dbf8 100755 --- a/tcar-scripts/tcar_getPathComponent.sh +++ b/tcar-scripts/tcar_getPathComponent.sh @@ -30,12 +30,6 @@ function tcar_getPathComponent { - # Define short options. - local ARGSS='' - - # Define long options. - local ARGSL='release,release-major,release-minor,release-pattern,architecture,architecture-pattern,motif,motif-name,motif-version,motif-pattern,repo-dir' - # Define release pattern. local VERSION="(([[:digit:]]+)(\.([[:digit:]]+))?)" @@ -47,21 +41,12 @@ function tcar_getPathComponent { # motif component inside the path strings. local THEME_MOTIF="Themes/Motifs/(([[:alnum:]]+)/(${VERSION}))" - # 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 TCAR_MODULE_ARGUMENT='' - - # 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. - tcar_setModuleArguments "${@}" - - # Redefine positional parameters using TCAR_MODULE_ARGUMENT variable. - eval set -- "${TCAR_MODULE_ARGUMENT}" - # Define location we want to apply verifications to. - local LOCATION=$(echo ${@} | sed -r 's!^.*--[[:space:]](.+)$!\1!') + local LOCATION=${1} + + # Remove location from positional parameters, so only the option + # remain. + shift 1 # Look for options passed through positional parameters. while true;do diff --git a/tcar-scripts/tcar_setModuleEnvironmentScripts.sh b/tcar-scripts/tcar_setModuleEnvironmentScripts.sh index 728ac63..bd9df2f 100755 --- a/tcar-scripts/tcar_setModuleEnvironmentScripts.sh +++ b/tcar-scripts/tcar_setModuleEnvironmentScripts.sh @@ -37,8 +37,9 @@ function tcar_setModuleEnvironmentScripts { local TCAR_MODULE_SCRIPTS="${TCAR_MODULE_INIT_FILE}" if [[ -d ${TCAR_MODULE_DIR} ]];then TCAR_MODULE_SCRIPTS="${TCAR_MODULE_SCRIPTS} - $(tcar_getFilesList ${TCAR_MODULE_DIR} \ - --pattern="${TCAR_MODULE_DIR}/${TCAR_MODULE_NAME}_[[:alnum:]]+\.sh$" --type='f')" + $(tcar_getFilesList \ + -p "${TCAR_MODULE_DIR}/${TCAR_MODULE_NAME}_[[:alnum:]]+\.sh$" \ + -t 'f' ${TCAR_MODULE_DIR})" fi # Verify the list of files. If no function file exists for the