[net.bugs.4bsd] grep 'RE botch' error

naren@clan.UUCP (Narendra Mehta) (08/18/86)

	grep '[' file

	gives a 'RE botch' error on our VAX-750 running 4.2BSD.  If the fix
has already been posted, could someone please mail me the diffs?  Thanks.
------------------------------------------------------------------
Narendra Mehta, 
Systems & Computer Engineering Department, Carleton University, Ottawa
UUCP:	{allegra,decvax,ihnp4,linus,utzoo}!watmath!clan!naren

bzs@bu-cs.BU.EDU (Barry Shein) (08/21/86)

>	grep '[' file
>
>	gives a 'RE botch' error on our VAX-750 running 4.2BSD.  If the fix
>has already been posted, could someone please mail me the diffs?  Thanks.
>------------------------------------------------------------------
>Narendra Mehta, 

That's not a bug, '[' is special to grep, try '\[' to escape it.

	-Barry Shein, Boston University

stephen@datacube.UUCP (08/22/86)

> 
> 	grep '[' file
> 
> 	gives a 'RE botch' error on our VAX-750 running 4.2BSD.  If the fix
> has already been posted, could someone please mail me the diffs?  Thanks.
> ------------------------------------------------------------------
> Narendra Mehta, 
> Systems & Computer Engineering Department, Carleton University, Ottawa
> UUCP:	{allegra,decvax,ihnp4,linus,utzoo}!watmath!clan!naren

Try grep '\[' file.

Stephen Watkins                    UUCP: ihnp4!datacube!stephen
Datacube Inc.; 4 Dearborn Rd.; Peabody, Ma. 01960; 617-535-6644

john@uw-nsr.UUCP (John Sambrook) (08/22/86)

In article <191@clan.UUCP> naren@clan.UUCP (Narendra Mehta) writes:
>
>	grep '[' file
>
>	gives a 'RE botch' error on our VAX-750 running 4.2BSD.  If the fix
>has already been posted, could someone please mail me the diffs?  Thanks.

The message is correct.  On our system it is a little clearer:

	grep: RE error 49: [ ] imbalance.

The "[" character is used to introduce a range specification, as in
"[a-z]" to match a single character in the range of "a" to "z".  To
search for a literal '[' character you should escape it with a 
backslash, as in:

	grep '\[' file

Hope this helps.


-- 
John Sambrook				Work: (206) 545-2018
University of Washington WD-12		Home: (206) 487-0180
Seattle, Washington  98195		UUCP: uw-beaver!uw-nsr!john

jsloan@wright.EDU (John Sloan) (08/22/86)

> >	grep '[' file
> >
> >	gives a 'RE botch' error on our VAX-750 running 4.2BSD.
> >Narendra Mehta, 
> That's not a bug, '[' is special to grep, try '\[' to escape it.
> 	-Barry Shein, Boston University

There is still a bug though: while [ is a special pattern operator to grep,
a single [ as in the example causes my 4.2BSD grep to go into a loop issuing
the "RE botch" error over and over. So while the error message is legitimate,
the ungraceful nonrecovery is not.
-- 
------------------------------------------------------------------------
John Sloan                         CSNET:      jsloan@WRIGHT.EDU
Wright State University            USENET:     ...!cbosgd!wright!jsloan
Computer Science and Engineering   ARPANET:    jsloan%wright@CSNET-RELAY
Dayton, OH 45435                   DECNET LAN: wright::jsloan
+1 513 873 2491, 2987              SMTP LAN:   jsloan@wright
UNIX is a registered trademark of AT&T.   Opinions expressed are my own.
  "I was a roadie for the Algorithmics on their 1986 Internet Tour"

dce@mips.UUCP (David Elliott) (08/23/86)

In article <191@clan.UUCP> naren@clan.UUCP (Narendra Mehta) writes:
>
>	grep '[' file
>
>	gives a 'RE botch' error on our VAX-750 running 4.2BSD.  If the fix
>has already been posted, could someone please mail me the diffs?  Thanks.

The fix is to put 'exit(2)' after the line

	fprintf(stderr, "RE botch\n");

in compile(), and the line

	fprintf(stderr, "RE error\n");

in advance(). This only applies to /usr/ucb/grep in 4.2 and 4.3.
Without these, you get an 'RE error' message followed by a whole
slew of 'RE botch' messages. There isn't any reason for grep to
keep going if the RE compiles wrong, anyway.

Admittedly, when I first saw this bug reported, I fired off a note
to Narendra saying it wasn't a bug. Like a fool (sorry Barry), I
didn't try it out first (I did this last year as well, an event Dave
Sherman may remember).

			David

ado@elsie.UUCP (Arthur David Olson) (08/26/86)

Index:	ucb/grep 4.1 Fix

Description:

> There is still a bug though: while [ is a special pattern operator to grep,
> a single [ as in the example causes my 4.2BSD grep to go into a loop issuing
> the "RE botch" error over and over. So while the error message is legitimate,
> the ungraceful nonrecovery is not.

Repeat-By:
	grep \[ /etc/passwd

Fix:
	Is to "ucbgrep.c"  As usual, the trade secret status of the code
	involved precludes a clearer posting.  The fix is the addition
	conditioned on "OLDVERSION" below; it goes at the end of the
	function "compile".

		    cerror:
			fprintf(stderr, "RE error\n");
		#ifndef OLDVERSION
			exit(2);
		#endif
		}
--
Bug/s is a Volkswagen/Warner Brothers trademark.
Wright is a Safeway trademark.
--
	UUCP: ..decvax!seismo!elsie!ado   ARPA: elsie!ado@seismo.ARPA
	DEC, VAX, Elsie & Ado are Digital, Borden & Ampex trademarks.

lepreau@utah-cs.UUCP (Jay Lepreau) (08/29/86)

On the contrary, this is fixed in the 4.3 release.  You
must be looking at 4.3 Beta.

dce@mips.UUCP (David Elliott) (09/01/86)

In article <3907@utah-cs.UUCP> lepreau@utah-cs.UUCP (Jay Lepreau) writes:
>On the contrary, this is fixed in the 4.3 release.  You
>must be looking at 4.3 Beta.

Sorry, but we have standard 4.3 and it's broken. You must understand that
the problem is in /usr/ucb/grep and not in /bin/grep in 4.3.

In other words, it's only half fixed.

BTW, why are there two greps in 4.x?

			David