[BusyBox] separating multiple sed commands

Rob Landley rob at landley.net
Sat Jan 3 12:21:09 UTC 2004


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 
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?  
(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... :)  
I'll try to give it a thump this weekend...

Rob




More information about the busybox mailing list