From cfa845ac9b70e0857d6034de9cc41dc2ca6f6716 Mon Sep 17 00:00:00 2001 From: Alain Reguera Delgado Date: Sep 19 2012 17:19:16 +0000 Subject: Update `Functions/Commons/cli_checkRepoDirSource.sh' file. --- diff --git a/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh b/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh index 3e67220..a11b9fa 100755 --- a/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh +++ b/Scripts/Bash/Functions/Commons/cli_checkRepoDirSource.sh @@ -1,7 +1,8 @@ #!/bin/bash # -# cli_checkRepoDirSource.sh -- This function provides input validation -# to repository entries considered as source locations. +# cli_checkRepoDirSource.sh -- This function sanitates the action +# value variable. The action value variable contains non-option +# arguments passed to centos-art.sh script. # # Copyright (C) 2009, 2010, 2011, 2012 The CentOS Project # @@ -25,34 +26,21 @@ function cli_checkRepoDirSource { - - # Define location in order to make this function reusable not just - # for action value variable but whatever value passed as first - # positional argument. - local LOCATION=$1 - - # Verify location. Assuming no location is passed as first - # positional parameter to this function, print an error message - # and stop script execution. - if [[ "$LOCATION" == '' ]];then - cli_printMessage "`gettext "The first positional parameter is required."`" --as-error-line - fi - # Check action value to be sure strange characters are kept far - # away from path provided. - cli_checkPathComponent $LOCATION + # away from the path provided. + cli_checkPathComponent --everything ${ACTIONVAL} # Redefine source value to build repository absolute path from - # repository top level on. As we are removing - # /home/centos/artwork/ from all centos-art.sh output (in order to - # save horizontal output space), we need to be sure that all - # strings begining with trunk/..., branches/..., and tags/... use - # the correct absolute path. That is, you can refer trunk's - # entries using both /home/centos/artwork/trunk/... or just - # trunk/..., the /home/centos/artwork/ part is automatically added - # here. - if [[ $LOCATION =~ '^(trunk|branches|tags)' ]];then - LOCATION=${TCAR_WORKDIR}/$LOCATION + # repository top level on. As we are removing the absolute path + # prefix (e.g., `/home/centos/artwork/') from all centos-art.sh + # output (in order to save horizontal output space), we need to be + # sure that all strings begining with `trunk/...', `branches/...', + # and `tags/...' use the correct absolute path. That is, you can + # refer trunk's entries using both + # `/home/centos/artwork/trunk/...' or just `trunk/...', the + # `/home/centos/artwork/' part is automatically added here. + if [[ $ACTIONVAL =~ '^(trunk|branches|tags)' ]];then + ACTIONVAL=${TCAR_WORKDIR}/$ACTIONVAL fi # Re-define source value to build repository absolute path from @@ -62,33 +50,15 @@ function cli_checkRepoDirSource { # a few levels up from the location we want to refer to as source # value. There is no need to pass the absolute path to it, just # refere it relatively. - if [[ -d ${LOCATION} ]];then - - # Add directory to the top of the directory stack. - pushd "$LOCATION" > /dev/null - - # Check directory existence inside the repository. - if [[ $(pwd) =~ "^${TCAR_WORKDIR}" ]];then - # Re-define source value using absolute path. - LOCATION=$(pwd) - else - cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line - fi - - # Remove directory from the directory stack. - popd > /dev/null - - elif [[ -f ${LOCATION} ]];then + if [[ -d ${ACTIONVAL} ]];then # Add directory to the top of the directory stack. - pushd "$(dirname "$LOCATION")" > /dev/null + pushd "$ACTIONVAL" > /dev/null # Check directory existence inside the repository. if [[ $(pwd) =~ "^${TCAR_WORKDIR}" ]];then # Re-define source value using absolute path. - LOCATION=$(pwd)/$(basename "$LOCATION") - else - cli_printMessage "`eval_gettext "The location \\\"\\\$LOCATION\\\" is not valid."`" --as-error-line + ACTIONVAL=$(pwd) fi # Remove directory from the directory stack. @@ -96,7 +66,4 @@ function cli_checkRepoDirSource { fi - # Output sanitated location. - echo $LOCATION - }