[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Sporadic superfluous successful exits

From: Aki Helin
Subject: Sporadic superfluous successful exits
Date: Wed, 08 Feb 2012 15:22:08 +0200
User-agent: Heirloom mailx 12.4 7/29/08


For some reason Grep appears to occasionally exit with 0 even when there
was no match. This could also be bug Bash, but I wasn't able to reproduce
this with other programs, and the failure seems to be more common with
some patterns, or pairs of a pattern and an input, which would suggest
that the issue is in Grep.

The following is enough to eventually reproduce this on Debian 6.0.4 
(x86_64) using the included version (GNU grep 2.6.3) and 2.10 from 
ftp.gnu.org. The shell is Bash is version 4.1.5(1)-release.

 $ wget haltp.org/aoh/misc/cout.sh
 $ while true; do grep RANDOM cout.sh && date; done

Nothing should happen, but I'm getting occasional dates as in

 $ while true
 > do
 > grep -q RANDOM tests/cout.sh && date
 > done
 Wed Feb  8 05:52:23 EET 2012
 Wed Feb  8 06:28:02 EET 2012

and for Grep 2.10

 $ while true; do $HOME/opt/grep/bin/grep RANDOM tests/cout.sh && date; done
 Wed Feb  8 14:56:00 EET 2012

Can anyone reproduce this, and if so, does it look like a Grep thing or
something else?

Aki Helin

reply via email to

[Prev in Thread] Current Thread [Next in Thread]