Discussion:
sed: missing support for empty regular expressions
Leah Neukirchen
2017-08-22 16:32:51 UTC
Permalink
Hi,

it seems busybox sed (v1.27.2) does not support empty regular
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 <***@vuxu.org> http://leah.zone
Denys Vlasenko
2017-08-23 15:57:20 UTC
Permalink
Post by Leah Neukirchen
Hi,
it seems busybox sed (v1.27.2) does not support empty regular
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.
% 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
% printf '%s\n' foo bar stop quux qux | busybox sed -n '/stop/!p;//q'
foo
% yes | busybox sed //q
y
Fixed in git, thanks.

Loading...