sed command in busybox

Rob Landley rob at landley.net
Sun Nov 20 06:11:35 UTC 2005


On Saturday 19 November 2005 20:08, Glenn L. McGrath wrote:
> > Yes.  However, they neglect to mention that when you put it inside a
> > bracket expression, backslash loses its special meaning, and \n is no
> > longer recognized to mean newline.
>
> I assume what i quoted above also applies to bracket expressions, so
> when they say under 9.3.5 RE Bracket Expression, rule one;
>
> "The special characters '.', '*', '[', and '\' (period, asterisk,
> left-bracket, and backslash, respectively) shall lose their special
> meaning within a bracket expression."
>
> I think it means that bracket expressions in sed, the '\' will lose all
> meaning except when followed by a n.
>
> I dunno, ive been confused by the spec before, maybe i have it wrong.

Some common real-world behaviors violate the spec.  Busybox doesn't do a whole 
lot with POSIXLY_CORRECT in this case (although there are a couple of applets 
that shows up in), we pretty much implement the behavior that people actually 
use without worrying so much about pedantic corner cases.

In square brackets, [n\] is perfectly valid so [\n] isn't that ambiguous.  On 
the other hand, I'm curious how one is supposed to match a right square 
bracket in a character list...

> > Since that says that \n is NOT a GNU extension, it sounds like "them"
> > should NOT include \n, but the way GNU sed operates in POSIXLY_CORRECT
> > mode, it apparently does.
>
> Maybe its a bug in GNU sed.

Wouldn't be the first one.

> > You can search the comp.unix.shell archives for:
> >
> >     retain_quoted v0.004
>
> Found it, i got an error trying to run it under busybox sed, "bad
> option in substitution expression", it has commands like "s/foo/bar/
> #baz" i think technically it should have a semicolon in there,
> i.e. "s/foo/bar/;#baz"

If gnu sed takes it, then I can at least try to do so.  However, technically 
speaking "s/foo/bar/#baz" _does_ imply that # is an option like g in "s///g" 
so it's the script that's wrong here...

Could someone send me a copy of the script?

> "Command verbs other than {, a, b, c, i, r, t, w, :, and # can be
> followed by a semicolon, optional <blank>s, and another command verb."
>
> I got it to run, and i see its output is different than GNU sed, I will
> see if i can derive a simpler test from it.

I'm all ears... :)

> Glenn

Rob



More information about the busybox mailing list