tests/path.sh: if root, skip tests involving unreadable scripts
These always fail when running as root, as root can access files regardless of permission bits. (cherry picked from commit a821fe13906ac8ef56162bebd7c3e976b973f91c)
This commit is contained in:
parent
62f8e744f1
commit
6e90d4d76c
|
|
@ -282,6 +282,10 @@ PATH=$path
|
|||
scr=$tmp/script
|
||||
exp=126
|
||||
|
||||
if [[ $(id -u) == '0' ]]; then
|
||||
print -u2 -r "${Command}[$LINENO]: warning: running as root: skipping tests involving unreadable scripts"
|
||||
else
|
||||
|
||||
: > $scr
|
||||
chmod a=x $scr
|
||||
{ got=$($scr; print $?); } 2>/dev/null
|
||||
|
|
@ -309,6 +313,8 @@ got=$($SHELL -c "$scr; print \$?" 2>/dev/null)
|
|||
got=$($SHELL -c "command $scr; print \$?" 2>/dev/null)
|
||||
[[ "$got" == "$exp" ]] || err_exit "\$SHELL -c of command of unreadable non-empty script should fail -- expected $exp, got" $got
|
||||
|
||||
fi # if [[ $(id -u) == '0' ]]
|
||||
|
||||
# whence -a bug fix
|
||||
cd "$tmp"
|
||||
ifs=$IFS
|
||||
|
|
|
|||
Loading…
Reference in New Issue