########################################################################
# #
# This software is part of the ast package #
# Copyright (c) 1982-2012 AT&T Intellectual Property #
# and is licensed under the #
# Eclipse Public License, Version 1.0 #
# by AT&T Intellectual Property #
# #
# A copy of the License is available at #
# (with md5 checksum b35adb5213ca9657e911e9befb180842) #
# #
# 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
# whence -a bug fix
cd "$tmp"
IFS=$'\n'
> ls
ok=
do if [[ $i == *"$PWD/ls" ]]
then ok=1
break;
fi
done
#whence -p bug fix
function foo
{
:
}
# whence -q bug fix
sleep 3
print 'function foobar { :;}' > foobar
autoload foobar;
for ((i=0; i < 25; i++))
do ( foobar )
done
exec {m}<& -
# whence -a bug fix
exitval=$?
fi
function myfun
{
print myfun
}
[[ $(user_to_group_relationship.hdr.query foobar) == foobar ]] 2> /dev/null || err_exit 'Cannot execute command with . in name when PATH and FPATH end in :.'
[[ $x == "$tmp/new/bin/echo" ]] || err_exit 'nonexistant FPATH directory in .paths file causes path search to fail'
$SHELL 2> /dev/null <<- \EOF || err_exit 'path search problem with non-existant directories in PATH'
cat << END >/dev/null 2>&1
${.sh.version}
END