Hi,

I'm attaching to this mail an old proposal to clarify the exit status
description, included in the debian package: https://bugs.debian.org/446854

Regards,

Santiago
From 2432287712e802ce821e3158fb4f40a1a7b8b436 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Santiago=20Ruano=20Rinc=C3=B3n?= <santi...@debian.org>
Date: Tue, 7 Oct 2014 11:19:56 +0200
Subject: [PATCH] Simplify EXIT STATUS information

* doc/grep.in.1, doc/grep.texi: clarify information regarding exit status.
"A. Costa" <agco...@gis.net> wrote the original patch.
See: https://bugs.debian.org/446854
---
 doc/grep.in.1 | 16 ++++------------
 doc/grep.texi | 14 ++++----------
 2 files changed, 8 insertions(+), 22 deletions(-)

diff --git a/doc/grep.in.1 b/doc/grep.in.1
index 00d030a..44da7e9 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
+The exit status is 0 if selected lines are found, and 1 if not found.
+If an error occurred (and
 .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.
+are not used) the exit status is 2. (Note: POSIX error
+handling code should check for '2' or greater.)
 .
 .SH COPYRIGHT
 Copyright 1998-2000, 2002, 2005-2014 Free Software Foundation, Inc.
diff --git a/doc/grep.texi b/doc/grep.texi
index d7adcad..46361ce 100644
--- a/doc/grep.texi
+++ b/doc/grep.texi
@@ -1025,16 +1025,10 @@ 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.
+The exit status is 0 if selected lines are found, and 1 if not found.  If
+an error occurred (and @option{-q} or @option{--quiet} or
+@option{--silent} are not used) the exit status is 2. (Note: POSIX error
+handling code should check for '2' or greater.
 
 
 @node grep Programs
-- 
2.1.0

Attachment: signature.asc
Description: Digital signature

Reply via email to