Hello,

Path resolution seems to be different after the call of basename or mkdir.

What's wrong on my code ?

Thanks and regards,

Yves

Here is the output on my system :$ for t in basename mkdir none; do
TestCase.sh $t; done

Fxn TestPath : TestCase.sh -- start, it's OK
Fxn TestPath : TestCase.sh -- after basename
                                FAILED : without path
                                FAILED : with local path

Fxn TestPath : TestCase.sh -- start, it's OK
Fxn TestPath : TestCase.sh -- after mkdir
                                FAILED : without path
                                FAILED : with local path

Fxn TestPath : TestCase.sh -- start, it's OK
Fxn TestPath : TestCase.sh -- after none
$

Call the file TestCase.sh or change it in the variable CURRENT.

<<<<< Cut Here >>>>>
#!/usr/bin/ksh
set -u
(( $# != 1 )) && { print "Need an argument : basename, mkdir, none"; exit 1; }
CURRENT_FILE=TestCase.sh

function TestPath
{
        FILE=$1
        print -r "Fxn TestPath : $FILE -- $2"
        if [[ ! -x $FILE ]]
        then
                [[ -f $FILE ]] || print "\t\t\t\tFAILED : without path"
                [[ -f ./$FILE ]] || print "\t\t\t\tFAILED : with local path"
                [[ -f $PWD/$FILE ]] || print "\t\t\t\tFAILED : with pwd"
        fi
}

print ""
TestPath $CURRENT_FILE "start, it's OK"
case $1 in
        "basename")
                CURRENT=$(basename $0)
                ;;
        "mkdir")
                TMP=$PWD/TMP
                [[ -d $TMP ]] && rm -rf "$TMP"
                mkdir "$TMP" || { print -u 2 "$0: Unable to create folder 
$TMP"; exit 1; }
                ;;
        *)
                ;;
esac
TestPath $CURRENT_FILE "after $1"
<<<<< Cut Here >>>>>
_______________________________________________
ast-developers mailing list
[email protected]
https://mailman.research.att.com/mailman/listinfo/ast-developers

Reply via email to