diff options
author | Jim Meyering <jim@meyering.net> | 2006-07-25 15:23:59 +0000 |
---|---|---|
committer | Jim Meyering <jim@meyering.net> | 2006-07-25 15:23:59 +0000 |
commit | 3a208b14048121755eb01377f985372561a4b953 (patch) | |
tree | 4d8ca5fb2a8484f893b0943fe636fca4ae1aa0f7 /tests | |
parent | a321dfb09d5bdf5a5b2bd91db42d0ea51b29972e (diff) | |
download | coreutils-3a208b14048121755eb01377f985372561a4b953.tar.xz |
* src/ls.c (gobble_file): Make it so failure to stat a
non-command-line file provokes an exit status of 1, not 0.
Say "cannot access" rather than "cannot stat".
* tests/ls/stat-failed: New file/test, for the above.
* tests/ls/Makefile.am (TESTS): Add stat-failed.
Diffstat (limited to 'tests')
-rw-r--r-- | tests/ls/Makefile.am | 1 | ||||
-rwxr-xr-x | tests/ls/stat-failed | 36 |
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/ls/Makefile.am b/tests/ls/Makefile.am index 7c6ae5ab0..fc8af7c55 100644 --- a/tests/ls/Makefile.am +++ b/tests/ls/Makefile.am @@ -3,6 +3,7 @@ AUTOMAKE_OPTIONS = 1.2 gnits TESTS = \ + stat-failed \ stat-dtype \ inode dangle file-type recursive dired infloop \ rt-1 time-1 symlink-slash follow-slink no-arg m-option \ diff --git a/tests/ls/stat-failed b/tests/ls/stat-failed new file mode 100755 index 000000000..a7c006609 --- /dev/null +++ b/tests/ls/stat-failed @@ -0,0 +1,36 @@ +#!/bin/sh +# Verify that ls works properly when it fails to stat a file that is +# not mentioned on the command line. + +if test "$VERBOSE" = yes; then + set -x + ls --version +fi + +. $srcdir/../envvar-check +. $srcdir/../lang-default +PRIV_CHECK_ARG=require-non-root . $srcdir/../priv-check + +pwd=`pwd` +t0=`echo "$0"|sed 's,.*/,,'`.tmp; tmp=$t0/$$ +trap 'status=$?; cd $pwd; chmod -R u+rwx $t0; rm -rf $t0 && exit $status' 0 +trap '(exit $?); exit $?' 1 2 13 15 + +framework_failure=0 +mkdir -p $tmp || framework_failure=1 +cd $tmp || framework_failure=1 +mkdir d || framework_failure=1 +ln -s / d/s || framework_failure=1 +chmod 600 d || framework_failure=1 + +if test $framework_failure = 1; then + echo "$0: failure in testing framework" 1>&2 + (exit 1); exit 1 +fi + +fail=0 + +ls -Log d > out 2> err +test $? = 1 || fail=1 + +(exit $fail); exit $fail |