sed: missing support for empty regular expressions

Denys Vlasenko vda.linux at googlemail.com
Wed Aug 23 15:57:20 UTC 2017


On Tue, Aug 22, 2017 at 6:32 PM, Leah Neukirchen <leah at vuxu.org> wrote:
> 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

Fixed in git, thanks.


More information about the busybox mailing list