[BusyBox] separating multiple sed commands
Frank Lenaerts
lenaerts.frank at pandora.be
Sat Jan 3 13:00:04 UTC 2004
On Sat, Jan 03, 2004 at 06:21:09AM -0600, Rob Landley wrote:
> On Friday 02 January 2004 14:07, Frank Lenaerts wrote:
> > While migrating from a 0.60.x (busybox 0.60.5 in Debian Sid) to a
> > 1.0.0-preX (busybox-cvs version from 20031212 in Debian Sid,
> > corresponding to 1.0.0-pre4) busybox, I noticed a difference in the
> > sed's behaviour.
> >
> > In the older version, I could use a semicolon to separate sed
> > commands e.g.:
> >
> > sed 's/.*key=\(.*\)/\1/ ; s/ .*//' some_file ;
> >
> > In the newer version, this does not work anymore and I get a "sed: bad
> > option in substitution" error. When I rewrite the sed commands without
> > a semicolon however, everything works fine e.g.:
> >
> > sed '
> > s/.*key=\(.*\)/\1/
> > s/ .*//
> > ' some_file ;
> >
> > This can thus be used as a work-around, but I don't know if the fact
> > that using a semicolon to separate sed commands results in an error is
> > the purpose (i.e. a builtin limitation) or not (i.e. a bug).
>
> I rewrote the sed code fairly extensively, and if the GNU or BSD version can
It works with GNU sed and with Busybox's 0.60.5 sed.
> handle it, I'd call it a bug. I do remember that the logic for figuring out
> exactly what is and what isn't a search/replace option is a bit tricky...
>
> Could you post a datafile that the above expression is expected to work on?
In my case, some_file is actually /proc/cmdline (example below). Just
replace "key" with "root" or so.
FYI: I'm using this construct to retrieve the value of a key value
pair in the kernel commandline: first match ${key}= and then strip
everything after the value (indicated by a blank after it)
--- begin datafile ---
initrd=some-hostname/initrd.gz init=/linuxrc console=ttyS0,9600n81 rw root=/dev/ram0 path=some-hostname nic=eth0 BOOT_IMAGE=some-hostname/linux ip=192.168.1.81:192.168.1.121:192.168.1.1:255.255.255.0
--- end datafile ---
> (Before and after versions I can use as test cases? Never a bad thing to
> have an explicit test case when venturing into depths of a codebase... :)
In the example kernel commandline above, with "root" as "key", the
result (stdout) should be /dev/ram0.
> I'll try to give it a thump this weekend...
>
> Rob
--
lenaerts.frank at pandora.be
gpg fingerprint: A41E A399 5160 BAB9 AEF1 58F2 B92A F4AB 9FFB 3707
gpg key id: 9FFB3707
Those who do not understand Unix are condemned to reinvent it, poorly."
-- Henry Spencer
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20040103/aacacaf3/attachment-0002.pgp
More information about the busybox
mailing list