perl finds bug in fgrep(1)!
Bob Best
bob at dhw68k.cts.com
Mon Aug 15 05:16:49 AEST 1988
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 <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: README bad good text
# Wrapped by bob at dallnix on Sun Aug 14 11:40:00 1988
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f 'README' -a "${1}" != "-c" ; then
echo shar: Will not clobber existing file \"'README'\"
else
echo shar: Extracting \"'README'\" \(949 characters\)
sed "s/^X//" >'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 at 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 at dhw68k.cts.com
More information about the Comp.unix.wizards
mailing list