3a1adda
From 50654566c77d1335870206f657507a2d1c23f628 Mon Sep 17 00:00:00 2001
3a1adda
From: =?utf-8?q?Ond=C5=99ej=20Va=C5=A1=C3=ADk?= <ovasik <at> redhat.com>
3a1adda
Date: Thu, 9 Oct 2008 10:56:54 +0200
3a1adda
Subject: [PATCH] doc: ls: clarify exit status description
3a1adda
3a1adda
* src/ls.c (exit_status): Clarify comments.
3a1adda
(usage): Clarify exit status description in --help output.
3a1adda
* doc/coreutils.texi (ls invocation): Clarify exit status documentation
3a1adda
Reported by Greg Metcalfe in <http://bugzilla.redhat.com/446294>.
3a1adda
---
3a1adda
 THANKS             |    1 +
3a1adda
 doc/coreutils.texi |    7 +++++--
3a1adda
 src/ls.c           |   16 ++++++++++++----
3a1adda
 3 files changed, 18 insertions(+), 6 deletions(-)
3a1adda
3a1adda
diff --git a/THANKS b/THANKS
3a1adda
index e6e48b3..d06f755 100644
3a1adda
--- a/THANKS
3a1adda
+++ b/THANKS
3a1adda
@@ -201,6 +201,7 @@ Guochun Shi                         gshi@ncsa.uiuc.edu
3a1adda
 GOTO Masanori                       gotom@debian.or.jp
3a1adda
 Greg Louis                          glouis@dynamicro.on.ca
3a1adda
 Greg McGary                         gkm@gnu.org
3a1adda
+Greg Metcalfe                       metcalfegreg@qwest.net
3a1adda
 Greg Schafer                        gschafer@zip.com.au
3a1adda
 Greg Troxel                         gdt@bbn.com
3a1adda
 Greg Wooledge                       gawooledge@sherwin.com
3a1adda
diff --git a/doc/coreutils.texi b/doc/coreutils.texi
3a1adda
index a0d2202..b7e044d 100644
3a1adda
--- a/doc/coreutils.texi
3a1adda
+++ b/doc/coreutils.texi
3a1adda
@@ -6073,8 +6073,11 @@ ls invocation
3a1adda
3a1adda
 @display
3a1adda
 0 success
3a1adda
-1 minor problems (e.g., a subdirectory was not found)
3a1adda
-2 serious trouble (e.g., memory exhausted)
3a1adda
+1 minor problems  (e.g., failure to access a file or directory not
3a1adda
+  specified as a command line argument.  This happens when listing a
3a1adda
+  directory in which entries are actively being removed or renamed.)
3a1adda
+2 serious trouble (e.g., memory exhausted, invalid option or failure
3a1adda
+  to access file or directory specified as a command line argument)
3a1adda
 @end display
3a1adda
3a1adda
 Also see @ref{Common options}.
3a1adda
diff --git a/src/ls.c b/src/ls.c
3a1adda
index e107162..108d669 100644
3a1adda
--- a/src/ls.c
3a1adda
+++ b/src/ls.c
3a1adda
@@ -715,11 +715,14 @@ static int exit_status;
3a1adda
 /* Exit statuses.  */
3a1adda
 enum
3a1adda
   {
3a1adda
-    /* "ls" had a minor problem (e.g., it could not stat a directory
3a1adda
-       entry).  */
3a1adda
+    /* "ls" had a minor problem.  E.g., while processing a directory,
3a1adda
+       ls obtained the name of an entry via readdir, yet was later
3a1adda
+       unable to stat that name.  This happens when listing a directory
3a1adda
+       in which entries are actively being removed or renamed.  */
3a1adda
     LS_MINOR_PROBLEM = 1,
3a1adda
3a1adda
-    /* "ls" had more serious trouble.  */
3a1adda
+    /* "ls" had more serious trouble (e.g., memory exhausted, invalid
3a1adda
+       option or failure to stat a command line argument.  */
3a1adda
     LS_FAILURE = 2
3a1adda
   };
3a1adda
3a1adda
@@ -4527,7 +4530,12 @@ colors, and can be set easily by the dircolors command.\n\
3a1adda
 "), stdout);
3a1adda
       fputs (_("\
3a1adda
 \n\
3a1adda
-Exit status is 0 if OK, 1 if minor problems, 2 if serious trouble.\n\
3a1adda
+Exit status:\n\
3a1adda
+0 if OK,\n\
3a1adda
+1 if minor problems (e.g., failure to access a file or directory not\n\
3a1adda
+  specified as a command line argument\n\
3a1adda
+2 if serious trouble (e.g., memory exhausted, invalid option or failure\n\
3a1adda
+  to access a file or directory specified as a command line argument).\n\
3a1adda
 "), stdout);
3a1adda
       emit_bug_reporting_address ();
3a1adda
     }
3a1adda
--
3a1adda
1.6.0.2.514.g23abd3