what should egrep '|root' /etc/passwd print? (Everything)

Brandon S. Allbery allbery at ncoast.UUCP
Sat Sep 24 03:51:23 AEST 1988


As quoted from <855 at yunexus.UUCP> by oz at yunexus.UUCP (Ozan Yigit):
+---------------
| In article <8492 at smoke.ARPA> Doug Gwyn  writes:
| >In article <44414 at beno.seismo.CSS.GOV> Rick Adams writes:
| >>What should 
| >>	egrep '|root' /etc/passwd
| >>print?
| >
| >The question of how to handle empty strings in regular expressions
| >does not have a clear-cut answer.  
| 
| Oh ??? Just what does '(foo)?' match on your egrep ?? It just happens
| to be the same thing as E|foo (E for Epsilon, or the null match),
| or exactly what rick wants to match. It had a clear cut answer before,
| but I am sure it is lost somewhere along the line. 
+---------------

But (foo)? is well-defined, whereas (|foo) is open to variant
interpretations, as shown.  Why not accept it?  If you're going to complain
about (|foo), why not complain about (^|foo) as well?

System V grep prints that weird error message because it uses /bin/ed's
regexp code; and ed re-uses the last regexp when presented with a null
regexp.  Perhaps a bit strange, but it indicates a missing option in the
regexp common code rather than a bug in grep, in my opinion.  (What say we
get AT&T to use Henry Spencer's V8 regexp code?)

++Brandon
-- 
Brandon S. Allbery, uunet!marque!ncoast!allbery			DELPHI: ALLBERY
	    For comp.sources.misc send mail to ncoast!sources-misc
"Don't discount flying pigs before you have good air defense." -- jvh at clinet.FI



More information about the Comp.unix.wizards mailing list