gnu/167009: grep(1): GNU grep -q can exit !0 even if strings found

David Wolfskill david at
Tue Apr 17 19:20:05 UTC 2012

The following reply was made to PR gnu/167009; it has been noted by GNATS.

From: David Wolfskill <david at>
To: Jilles Tjoelker <jilles at>
Cc: bug-followup at
Subject: Re: gnu/167009: grep(1): GNU grep -q can exit !0 even if strings found
Date: Tue, 17 Apr 2012 12:12:15 -0700

 Content-Type: text/plain; charset=us-ascii
 Content-Disposition: inline
 Content-Transfer-Encoding: quoted-printable
 On Tue, Apr 17, 2012 at 09:08:12PM +0200, Jilles Tjoelker wrote:
 > FreeBSD PR gnu/167009:
 > > [strings -a /usr/local/bin/bison | grep -qw /usr/local fails]
 > The peculiar thing is the shell, tcsh.
 > What happens is that grep -q terminates early, so that strings receives
 > SIGPIPE when it tries to write further data. Whereas the exit status
 > of a pipeline in sh is always the exit status of the last element so
 > that your command has the expected behaviour, this is different in tcsh.
 > Tcsh looks backwards for a failing command if the last element has exit
 > status 0, and returns the 141 corresponding to SIGPIPE.
 > ...
 Huh.  Thanks for the explanation.  :-}
 David H. Wolfskill				david at
 Depriving a girl or boy of an opportunity for education is evil.
 See for my public key.
 Content-Type: application/pgp-signature
 Content-Disposition: inline
 Version: GnuPG v2.0.19 (FreeBSD)

More information about the freebsd-bugs mailing list