Subject: pkg/22528: /usr/xpg4/bin/egrep is broken on SunOS.
To: None <gnats-bugs@gnats.NetBSD.org>
From: None <jonathan@perkin.org.uk>
List: netbsd-bugs
Date: 08/18/2003 12:24:41
>Number:         22528
>Category:       pkg
>Synopsis:       /usr/xpg4/bin/egrep is broken on SunOS.
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    pkg-manager
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Mon Aug 18 12:25:00 UTC 2003
>Closed-Date:
>Last-Modified:
>Originator:     Jonathan Perkin
>Release:        N/A
>Organization:
British Broadcasting Corporation
>Environment:
SunOS build0 5.8 Generic_108528-15 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
SunOS build1 5.9 Generic_112233-01 sun4u sparc SUNW,UltraSPARC-IIi-cEngine
>Description:
/usr/xpg4/bin/egrep -q on SunOS doesn't do what it says on the tin.
Fortunately (or not, depending on how you interpret "The
/usr/xpg4/bin/egrep utility is identical to /usr/xpg4/bin/grep -E"), invoking as /usr/xpg4/bin/grep -E works as expected.

$ echo "foo" > testfile

$ /usr/xpg4/bin/egrep -q foo testfile
Usage:  egrep [-c|-l|-q] [-bhinsvx] [file ...]
egrep [-c|-l|-q] [-bhinsvx] -e pattern... [-f pattern_file]...[file...]
egrep [-c|-l|-q] [-bhinsvx] [-e pattern]... -f pattern_file [file...]

$ echo $?
2

$ /usr/xpg4/bin/grep -E -q foo testfile

$ echo $?
0

Confirmed on SunOS 5.7, 5.8, 5.9
>How-To-Repeat:
pkgsrc/mk/bulk/bsd.bulk-pkg.mk uses ${EGREP} -q quite a lot, so can be
verified using that.  Breakage for bulk builds is what pointed out the
bug, and there may be other uses of it within specific packages.
>Fix:
http://www.perkin.org.uk/projects/netbsd/egrep.diff

Index: defs.SunOS.mk
===================================================================
RCS file: /cvsroot/pkgsrc/mk/defs.SunOS.mk,v
retrieving revision 1.62
diff -u -r1.62 defs.SunOS.mk
--- defs.SunOS.mk       2003/07/11 14:33:45     1.62
+++ defs.SunOS.mk       2003/08/18 12:09:01
@@ -15,7 +15,7 @@
 DC?=           /usr/bin/dc
 DIRNAME?=      /usr/bin/dirname
 ECHO?=         /usr/ucb/echo
-EGREP?=                /usr/xpg4/bin/egrep
+EGREP?=                /usr/xpg4/bin/grep -E
 EXPR?=         /usr/xpg4/bin/expr
 FALSE?=                /usr/bin/false
 FGREP?=                /usr/xpg4/bin/fgrep
>Release-Note:
>Audit-Trail:
>Unformatted: