[BusyBox] Today's sed bug, with patch.

Rob Landley rob at landley.net
Mon Apr 12 08:51:25 UTC 2004


So I'm building a linux from scratch system, using a working script to do this 
that the _only_ change to is that gnu sed has been replaced with busybox sed.  
And ncurses' install phase hangs.  I trace it down, and it's trying to run 
gawk.  (Insert obligatory doubletake, but this is FSF code we're talking 
about, so...)

It turns out gawk shells out to sed, ala "sed -f /tmp/blah file.h".  The 
/tmp/blah file is basically empty (it contains one character, a newline).  So 
basically, gawk is using sed as "cat".  With gnu sed, it works like cat, 
anyway.

With busybox sed, it tests if its command list is empty after parsing the 
command line, and if the list is empty it takes the first file argument as a 
sed command string, and if that leaves the file list empty it tries to read 
the data to operate on from stdin.  (Hence the hang, since nothing's coming 
in on stdin...)

It _should_ be testing whether there were any instances of -f or -e, not 
whether it actually got any commands.  Using sed as cat may be kind of 
stupid, but it's valid and gawk relies on this behavior.

Here's a patch to fix it, turning a couple of ints into chars in hopes of 
saving a bit of the space this adds.  Comments?

Rob
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fixsed.patch
Type: text/x-diff
Size: 919 bytes
Desc: not available
Url : http://lists.busybox.net/pipermail/busybox/attachments/20040412/575bd8fc/attachment.bin 


More information about the busybox mailing list