Subject: bug: empty regex exits with error when following 2-address like LINENO,/RE/

From: "Don Crissti" <[email-masked]>
Date: Thu, 15 Mar 2018 21:20:37 +0100

The manual states that

"the empty regular expression ‘//’ repeats the last regular expression match"

however this does not work when the empty regex follows a 2-address of the form LINE_NUMBER,/REGEX/

e.g.

# printf %s\\n {1..5} | sed '2,/5/{//!d}'

fails with

"sed: -e expression #1, char 0: no previous regular expression"

instead of printing

1

5

If it matters, a 2-address like /REGEX/,LINE_NUMBER works as expected e.g.:

# printf %s\\n {1..5} | sed '/2/,5{//!d}'

correctly prints

1

2

This is with gnu sed 4.4 on archlinux, vanilla.