[BusyBox] More on sed behavior...

Rob Landley rob at landley.net
Wed Oct 1 05:50:18 UTC 2003


So now that the patch has been applied, I'm fixing up the failing tests from 
the testsuite.  The test "testsuite/sed/sed-append-next-line" is effectively 
this:

echo -e "a\nb\nc" | sed -e 'N;p'



Which gives this with gnu sed and busybox sed:

$ echo -e "a\nb\nc" | sed -e 'N;p'
a
b
a
b
c

$ echo -e "a\nb\nc" | ../busybox sed -e 'N;p'
a
b
a
b
$

Our behavior on this one is, in fact, correct according to The Open Group:
	If no next line of input is available, the N command verb shall branch to the
 	end of the script and quit without starting a new cycle or copying the
	 pattern space to standard output.

Gnu is copying the pattern space to stdout, and appending a newline.  This is 
not filling in a gray area or adding extra behavior for otherwise invalid 
inputs, this is a direct violation of what the spec explicitly says to do in 
a defined case.

Should I fix this one to be like gnu, leave it compliant with the spec, or 
reintroduce the #ifdef gnu_compatability?  (For the moment I'm leaving it 
alone: anybody who depends on this is asking for trouble...)

Rob


More information about the busybox mailing list