help - busybox- grep and Source command

Juergen Hennerich juergen at hennerich.eu
Mon Sep 4 18:48:17 UTC 2006


Rich Felker schrieb:
> On Mon, Sep 04, 2006 at 06:14:10PM +0200, Juergen Hennerich wrote:
>> Rich Felker schrieb:
>>> On Mon, Sep 04, 2006 at 01:13:33PM +0200, Juergen Hennerich wrote:
>>>> Juergen Hennerich schrieb:

> 
>>> Also using ^ or $ the way you used them is possibly not POSIX; I
>>> forget the details. :(
>> I don't see why it shouldn't be POSIX conform.
> 
> 9.3.6 BREs Matching Multiple Characters
> [...]
> 2. A subexpression can be defined within a BRE by enclosing it between
> the character pairs "\(" and "\)". Such a subexpression shall match
> whatever it would have matched without the "\(" and "\)", except that
> anchoring within subexpressions is optional behavior; see BRE
> Expression Anchoring.
> 
> 9.3.8 BRE Expression Anchoring
> [...]
> A circumflex ( '^' ) shall be an anchor when used as the first
> character of an entire BRE. The implementation may treat the
> circumflex as an anchor when used as the first character of a
> subexpression.
> 
> [And similar for $]
> 
You have overlooked that I used grep -E. This (might be) limitations 
only apply to BRE, but I was using ERE. Also I think most 
implementations support it anyhow.

For ERE this applies:

An ERE can be limited to matching strings that begin or end a line; this 
is called "anchoring". The circumflex and dollar sign special characters 
shall be considered ERE anchors when used anywhere outside a bracket 
expression.

Using BRE makes the expression a little bit more complicated.

grep '^\(\|.*[^a-zA-Z0-9_]\)word\([^a-zA-Z0-9_].*\|\)$'

I guess nearly every implementation now supports extended RE. With 
uClibc, you can't even select to omit ERE support.

BRE really suck!

> Rich
> 
> _______________________________________________
> busybox mailing list
> busybox at busybox.net
> http://busybox.net/cgi-bin/mailman/listinfo/busybox
> 
> 




More information about the busybox mailing list