Path: utzoo!attcan!uunet!ncrlnk!ncrcae!ece-csc!ncsuvx!gatech!cwjcc!hal!ncoast!allbery From: allbery@ncoast.UUCP (Brandon S. Allbery) Newsgroups: comp.unix.wizards Subject: Re: what should egrep '|root' /etc/passwd print? (Everything) Message-ID: <12599@ncoast.UUCP> Date: 23 Sep 88 17:51:23 GMT References: <44414@beno.seismo.CSS.GOV> <8492@smoke.ARPA> <855@yunexus.UUCP> Reply-To: allbery@ncoast.UUCP (Brandon S. Allbery) Followup-To: comp.unix.wizards Organization: Cleveland Public Access UN*X, Cleveland, Oh Lines: 32 As quoted from <855@yunexus.UUCP> by oz@yunexus.UUCP (Ozan Yigit): +--------------- | In article <8492@smoke.ARPA> Doug Gwyn writes: | >In article <44414@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@clinet.FI