path.sh revision da2e3ebdc1edfbc5028edf1354e7dd2fa69a7968
########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2007 AT&T Knowledge Ventures #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Knowledge Ventures #
# #
# A copy of the License is available at #
# (with md5 checksum 059e8cd6165cb4c31e351f2b69388fd9) #
# #
# Information and Software Systems Research #
# AT&T Research #
# Florham Park NJ #
# #
# David Korn <dgk@research.att.com> #
# #
########################################################################
function err_exit
{
print -u2 -n "\t"
let Errors+=1
}
alias err_exit='err_exit $LINENO'
integer Errors=0
function a
{
ok$$
}
unset PATH
a
}
function lock_unlock
{
typeset -x PATH=''
}
typeset -ft lock_unlock
then err_exit 'not an error to run ksh on a directory'
fi
print 'print hi' > ls
fi
then err_exit 'PATH export in command substitution not working'
fi
pwd=$PWD
# get rid of leading and trailing : and trailing :.
break
fi
done
print 'print hello' > date
print 'print notfound' > $cmd
> foo
for PATH in $path :$path $path: .:$path $path: $path:. $PWD::$path $PWD:.:$path $path:$PWD $path:.:$PWD
do
# print path=$PATH $(whence date)
# print path=$PATH $(whence "$cmd")
"$cmd"
then err_exit "leading : in path not working"
fi
(
builtin chmod
if [[ ! -x noexec ]]
else exit 126
fi
)
status=$?
unset FPATH
then err_exit 'programs in . should not be found'
fi
PATH=$d:
then err_exit 'trailing : in pathname not working'
fi
PATH=:$d
then err_exit 'leading : in pathname not working'
fi
then err_exit 'pathname not restored after scoping'
fi
fi
cd /
then PATH=
if [[ $(whence rm) ]]
then err_exit 'setting PATH to Null not working'
fi
unset PATH
then err_exit 'unsetting path not working'
fi
fi
x=$(whence rm)
y=$(whence rm)
x=$(whence ls)
cd "${x%/ls}"
[[ $status == 127 ]] || err_exit "not found command with ERR trap exit status $status -- expected 127"
[[ $status == 126 ]] || err_exit "non executable command ERR trap exit status $status -- expected 126"