########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2010 AT&T Intellectual Property #
# and is licensed under the #
# Common Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# 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
cd $tmp || exit
+++
+++
p=$PATH
PATH=$p
print print ok > $tmp/ok
/bin/chmod 755 $tmp/ok
function a
{
typeset -x PATH=$tmp
ok
}
path=\$PATH
unset PATH
a
PATH=\$path
}
EOF
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=$?
done
exp=''
unset FPATH
done
exp=''
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"
# universe via PATH
builtin getconf
[[ $(PATH=/usr/ucb/bin:/usr/bin echo -n ucb) == 'ucb' ]] || err_exit "ucb universe echo ignores -n option"
[[ $(PATH=/usr/xpg/bin:/usr/bin echo -n att) == '-n att' ]] || err_exit "att universe echo does not ignore -n option"
exp=126
: > $scr
[[ "$got" == "$exp" ]] || err_exit "command of unreadable empty script should fail -- expected $exp, got $got"
[[ "$(:; $scr; print $?)" == "$exp" ]] 2>/dev/null || err_exit "unreadable empty script in [[ ... ]] should fail -- expected $exp"
[[ "$(:; command $scr; print $?)" == "$exp" ]] 2>/dev/null || err_exit "command unreadable empty script in [[ ... ]] should fail -- expected $exp"
[[ "$got" == "$exp" ]] || err_exit "\$SHELL -c of unreadable empty script should fail -- expected $exp, got" $got
[[ "$got" == "$exp" ]] || err_exit "\$SHELL -c of command of unreadable empty script should fail -- expected $exp, got" $got
print : > $scr
[[ "$got" == "$exp" ]] || err_exit "unreadable non-empty script should fail -- expected $exp, got $got"
[[ "$got" == "$exp" ]] || err_exit "command of unreadable non-empty script should fail -- expected $exp, got $got"
[[ "$(:; $scr; print $?)" == "$exp" ]] 2>/dev/null || err_exit "unreadable non-empty script in [[ ... ]] should fail -- expected $exp"
[[ "$(:; command $scr; print $?)" == "$exp" ]] 2>/dev/null || err_exit "command unreadable non-empty script in [[ ... ]] should fail -- expected $exp"
[[ "$got" == "$exp" ]] || err_exit "\$SHELL -c of unreadable non-empty script should fail -- expected $exp, got" $got
[[ "$got" == "$exp" ]] || err_exit "\$SHELL -c of command of unreadable non-empty script should fail -- expected $exp, got" $got