diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2014-10-07 08:23:21 -0700 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2014-10-07 09:23:26 -0700 |
commit | e0149d0db994931e3f5390e797cdb2ad7d56d143 (patch) | |
tree | 204363fd1d85cfc565d008fa2717c471d1399113 | |
parent | 0406d130b73a2af380f41223014323323b9554d7 (diff) | |
download | grep-e0149d0db994931e3f5390e797cdb2ad7d56d143.tar.gz |
doc: clarify exit status
Reported by Santiago Ruano Rincón in: http://bugs.gnu.org/18651
* doc/grep.in.1 (EXIT STATUS):
* doc/grep.texi (Exit Status): Clarify.
-rw-r--r-- | doc/grep.in.1 | 16 | ||||
-rw-r--r-- | doc/grep.texi | 17 |
2 files changed, 10 insertions, 23 deletions
diff --git a/doc/grep.in.1 b/doc/grep.in.1 index 00d030ac..16b94b28 100644 --- a/doc/grep.in.1 +++ b/doc/grep.in.1 @@ -1143,23 +1143,15 @@ when is not set. . .SH "EXIT STATUS" -Normally, the exit status is 0 if selected lines are found and 1 otherwise. -But the exit status is 2 if an error occurred, unless the +Normally the exit status is 0 if a line is selected, 1 if no lines +were selected, and 2 if an error occurred. However, if the .B \-q or .B \-\^\-quiet or .B \-\^\-silent -option is used and a selected line is found. -Note, however, that \s-1POSIX\s0 only mandates, for programs such as -.BR grep , -.BR cmp , -and -.BR diff , -that the exit status in case of error be greater than 1; -it is therefore advisable, for the sake of portability, -to use logic that tests for this general condition -instead of strict equality with\ 2. +is used and a line is selected, the exit status is 0 even if an error +occurred. . .SH COPYRIGHT Copyright 1998-2000, 2002, 2005-2014 Free Software Foundation, Inc. diff --git a/doc/grep.texi b/doc/grep.texi index d7adcadd..da9a1bee 100644 --- a/doc/grep.texi +++ b/doc/grep.texi @@ -1025,17 +1025,12 @@ and only when @env{POSIXLY_CORRECT} is not set. @cindex exit status @cindex return status -Normally, the exit status is 0 if selected lines are found and 1 otherwise. -But the exit status is 2 if an error occurred, unless the @option{-q} or -@option{--quiet} or @option{--silent} option is used and a selected line -is found. -Note, however, that POSIX only mandates, -for programs such as @command{grep}, @command{cmp}, and @command{diff}, -that the exit status in case of error be greater than 1; -it is therefore advisable, for the sake of portability, -to use logic that tests for this general condition -instead of strict equality with@ 2. - +Normally the exit status is 0 if a line is selected, 1 if no lines +were selected, and 2 if an error occurred. However, if the +@option{-q} or @option{--quiet} or @option{--silent} option is used +and a line is selected, the exit status is 0 even if an error +occurred. Other @command{grep} implementations may exit with status +greater than 2 on error. @node grep Programs @section @command{grep} Programs |