1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
|
# Hey, Emacs! This is a -*- sh -*- script.
#
# The test suite fails if run by root, because when you are root,
# "test -w foo" returns 0 even for read-only files because root can
# write to them.
#
# The test suite depends on being able to accurately detect a readonly file.
# Execute in a subshell so that we can use "trap ... 0" and
# ensure that the temporary file is removed before we reach
# the end of this file.
(
f=/tmp/foo.$$.tmp
# Use rm and echo rather than risking a missing "touch".
rm -f $f ; echo > $f
# Remove temporary file on exit.
trap "rm -f $f" 0
chmod 400 $f
if test -f $f
then
if test -w $f
then
miscarry "Please do not run the suite as root"
fi
else
miscarry "Could not create $f (or buggy test(1))"
fi
unset f
) || exit $?
|