diff options
author | Jim Meyering <meyering@redhat.com> | 2009-09-28 18:29:02 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-09-29 07:28:39 +0200 |
commit | 242689c7f93de72693979f877dd31b3ef7178eea (patch) | |
tree | 29bc802c220b4d78ff9a1c3d659bc77aa898da9c | |
parent | 30c65cd49c98e56b65beef8812a4a25df4b1178a (diff) | |
download | coreutils-242689c7f93de72693979f877dd31b3ef7178eea.tar.xz |
ls: with -LR, exit with status 2 upon detecting a cycle
* src/ls.c (print_dir): Diagnosing the cycle is not enough.
Also set exit status to 2. This is what Solaris' /bin/ls does, too.
* tests/ls/infloop: Rework test: match both expected stdout and stderr.
Require an exit status of 2 in this case.
* doc/coreutils.texi (ls invocation): Mention that a loop provokes
in an exit status of 2.
* NEWS (Bug fixes): Mention it.
Reported by Yang Ren in http://bugzilla.redhat.com/525402.
* THANKS: Correct ordering of Yang Ren's names.
-rw-r--r-- | NEWS | 2 | ||||
-rw-r--r-- | THANKS | 2 | ||||
-rw-r--r-- | doc/coreutils.texi | 5 | ||||
-rw-r--r-- | src/ls.c | 1 | ||||
-rwxr-xr-x | tests/ls/infloop | 25 |
5 files changed, 20 insertions, 15 deletions
@@ -16,6 +16,8 @@ GNU coreutils NEWS -*- outline -*- when the color of a more specific type is disabled. [bug introduced in coreutils-5.90] + ls -LR exits with status 2, not 0, when it encounters a cycle + ** Portability On Solaris 9, many commands would mistakenly treat file/ the same as @@ -493,7 +493,7 @@ Ralph Loader loader@maths.ox.ac.uk Raul Miller moth@magenta.com Raúl Núñez de Arenas Coronado raul@pleyades.net Reuben Thomas rrt@sc3d.org -Ren Yang ryang@redhat.com +Yang Ren ryang@redhat.com Richard A Downing richard.downing@bcs.org.uk Richard Braakman dark@xs4all.nl Richard Dawe rich@phekda.freeserve.co.uk diff --git a/doc/coreutils.texi b/doc/coreutils.texi index b10cc100c..5026e7607 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -6113,8 +6113,9 @@ Exit status: 1 minor problems (e.g., failure to access a file or directory not specified as a command line argument. This happens when listing a directory in which entries are actively being removed or renamed.) -2 serious trouble (e.g., memory exhausted, invalid option or failure - to access file or directory specified as a command line argument) +2 serious trouble (e.g., memory exhausted, invalid option, failure + to access a file or directory specified as a command line argument + or a directory loop) @end display Also see @ref{Common options}. @@ -2471,6 +2471,7 @@ print_dir (char const *name, char const *realname, bool command_line_arg) error (0, 0, _("%s: not listing already-listed directory"), quotearg_colon (name)); closedir (dirp); + set_exit_status (true); return; } diff --git a/tests/ls/infloop b/tests/ls/infloop index 419d7a9f7..b77f88cdb 100755 --- a/tests/ls/infloop +++ b/tests/ls/infloop @@ -1,7 +1,7 @@ #!/bin/sh # show that the following no longer makes ls infloop # mkdir loop; cd loop; ln -s ../loop sub; ls -RL - +# Also ensure ls exits with status = 2 in that case. # Copyright (C) 2001-2002, 2004, 2006-2009 Free Software Foundation, Inc. # This program is free software: you can redistribute it and/or modify @@ -27,21 +27,22 @@ fi mkdir loop || framework_failure ln -s ../loop loop/sub || framework_failure -fail=0 - -ls -RL loop 2>err | head -n 7 > out -# With an inf-looping ls, out will contain these 7 lines: -cat <<EOF > bad +cat <<\EOF > exp-out || framework_failure loop: sub +EOF -loop/sub: -sub - -loop/sub/sub: +cat <<\EOF > exp-err || framework_failure +ls: loop/sub: not listing already-listed directory EOF -# Make sure we don't get the "bad" output. -compare out bad > /dev/null 2>&1 && fail=1 +fail=0 + +timeout 1 ls -RL loop 2>err > out +# Ensure that ls exits with status 2 upon detecting a cycle +test $? = 2 || fail=1 + +compare err exp-err || fail=1 +compare out exp-out || fail=1 Exit $fail |