Xref: utzoo comp.bugs.sys5:524 comp.unix.wizards:10452
Path: utzoo!yunexus!geac!syntron!jtsv16!uunet!peregrine!zardoz!dhw68k!bob
From: bob@dhw68k.cts.com (Bob Best)
Newsgroups: comp.bugs.sys5,comp.unix.wizards
Subject: perl finds bug in fgrep(1)!
Summary: fgrep(1) chokes on extraction
Keywords: fgrep bug
Message-ID: <10535@dhw68k.cts.com>
Date: 14 Aug 88 19:16:49 GMT
Article-I.D.: dhw68k.10535
Reply-To: bob@dhw68k.cts.com (Bob Best)
Organization: Wolfskill residence; Anaheim, CA (USA)
Lines: 92

The enclosed shar file contains a set of files that provide evidence that
the SYSV fgrep(1) is broken.  I discovered this while doing some benchmarks
between /bin/fgrep and a perl version of fgrep.
----------------cut here-------------------
#! /bin/sh
# This is a shell archive.  Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file".  To overwrite existing
# files, type "sh file -c".  You can also feed this as standard input via
# unshar, or by typing "sh 'README' <<'END_OF_FILE'
XWhile doing some benchmarking between a perl version of fgrep and the
XSYSV binary version of fgrep, I discovered that the perl version was
Xextracting more lines containing the pattern than the SYSV version.
XI asked myself, "is it possible that users have been relying for years
Xon a grep tool that has only now been found faulty?"  Several more
Xtests using randomly extracted words from /usr/dict/words convinced me
Xthat, indeed, the perl version had found a bug in the SYSV version.
X
XIn an effort to narrow down the bug as much as possible, I trimmed text until
XI finally arrived at the enclosed files that manifest the bug.
XTo verify the result, I tested this using fgrep on two different systems
Xrunning SYSV Unix.
X
XTo test this on your system, do the following:
X
Xfgrep -f bad text
Xfgrep -f good text
X
XIf your system has the bug, the test using 'bad' will fail to extract the
Xline that contains the string 'stall'.
X
XBob Best (bob@dhw68k.cts.com)
END_OF_FILE
if test 949 -ne `wc -c <'README'`; then
    echo shar: \"'README'\" unpacked with wrong size!
fi
# end of 'README'
fi
if test -f 'bad' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'bad'\"
else
echo shar: Extracting \"'bad'\" \(26 characters\)
sed "s/^X//" >'bad' <<'END_OF_FILE'
Xinsouciant
Xnichrome
Xstall
END_OF_FILE
if test 26 -ne `wc -c <'bad'`; then
    echo shar: \"'bad'\" unpacked with wrong size!
fi
# end of 'bad'
fi
if test -f 'good' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'good'\"
else
echo shar: Extracting \"'good'\" \(26 characters\)
sed "s/^X//" >'good' <<'END_OF_FILE'
Xincreasing
Xnichrome
Xstall
END_OF_FILE
if test 26 -ne `wc -c <'good'`; then
    echo shar: \"'good'\" unpacked with wrong size!
fi
# end of 'good'
fi
if test -f 'text' -a "${1}" != "-c" ; then 
  echo shar: Will not clobber existing file \"'text'\"
else
echo shar: Extracting \"'text'\" \(21 characters\)
sed "s/^X//" >'text' <<'END_OF_FILE'
XI am installing Unix
END_OF_FILE
if test 21 -ne `wc -c <'text'`; then
    echo shar: \"'text'\" unpacked with wrong size!
fi
# end of 'text'
fi
echo shar: End of shell archive.
exit 0
-- 
Bob Best
uucp: ...{trwrb,hplabs}!felix!dhw68k!bob	InterNet: bob@dhw68k.cts.com