sed: missing support for empty regular expressions

Leah Neukirchen leah at vuxu.org
Tue Aug 22 16:32:51 UTC 2017


Hi,

it seems busybox sed (v1.27.2) does not support empty regular
expressions as by POSIX, but instead matches the empty string:

>> If an RE is empty (that is, no pattern is specified) sed shall
>> behave as if the last RE used in the last command applied (either
>> as an address or as part of a substitute command) was specified.

GNU, OpenBSD, p9p:
% printf '%s\n' foo bar stop quux qux | sed -n '/stop/!p;//q'
foo
% yes | sed //q    
GNU: sed: -e expression #1, char 0: no previous regular expression
OpenBSD: sed: first RE may not be empty
p9p: sed: First RE may not be null

Busybox:
% printf '%s\n' foo bar stop quux qux | busybox sed -n '/stop/!p;//q' 
foo
% yes | busybox sed //q
y

thx,
-- 
Leah Neukirchen  <leah at vuxu.org>  http://leah.zone


More information about the busybox mailing list