help - busybox- grep and Source command

Rich Felker dalias at aerifal.cx
Mon Sep 4 17:22:03 UTC 2006


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:
> >>
> >>> grep -w word <-> grep -E '(^|[^:alnum:_])word([^:alnum:_]|$)'
> >>>
> >> I totally forgot: While this is not POSIX (I think), the anchors '\>' 
> >> '\<' are most likely also supported.
> > 
> > These are not POSIX and intentionally omitted from my implementation.
>  From what implementation?
> 
> Since grep uses the libc regex support it should support "\>" and "\<" 
> on all platforms, on which the libc has support for it. This is glibc 
> (of course) and uClibc (I've tested it). Of course if you write your own 
> libc, then you are free to not support those. And yes, they are 
> definitely not in POSIX, I think they are from vi.

Yes.

> > 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 $]

Rich




More information about the busybox mailing list