sed command in busybox

Glenn L. McGrath bug1 at iinet.net.au
Sat Nov 19 05:52:44 UTC 2005


On Fri, 18 Nov 2005 21:19:02 -0500
John Kelly <jakelly at shtc.net> wrote:

> On Thu, 17 Nov 2005 16:35:08 -0600, Rob Landley <rob at landley.net>
> wrote:
> 
> >> Trying to be the real sed is a real big job.  Maybe too big.
> 
> >Nope, we already are a real sed.  (By "real" I mean "susv3 with any gnu 
> >extensions that anything I tried actually broke due to the lack of".
> 
> 
> I use a sed script which makes frequent use of a bracket expression
> which needs to say [not newline] among other things.  For example,
> 
>     [^\"'\n]
> 
> which means not backslash, not double quote, not single quote, and not
> newline.

I just did a test with GNU sed and busybox sed and they apear to both
do the same thing, or the test is not what your saying.

$ cat test.sed
/[^\"'\n]/p
$ cat test.dat
1
\
2
"
3
'
4

5
$ busybox sed -nf test.sed test.dat
1
2
3
4
5

> The backslash loses its special meaning inside a bracket expression
> (as the first backlslash in that expression is taken literally), but
> GNU sed recognizes the special case of \n to be an escape which means
> newline, even within the bracket expression.

The special case of \n is in the POSIX specifcation

"The escape sequence '\n' shall match a <newline> embedded in the
pattern space. A literal <newline> shall not be used in the BRE of a
context address or in the substitute function."

> I don't expect busybox sed to be GNU, but this is one reason why it's
> not "real" to me.

Do you have an example that we can run to see the different behavious of
busybox and GNU sed ?


Thanks

Glenn



More information about the busybox mailing list