Subject: bug#32592: s with i modifier seems to work incorrectly

From: Assaf Gordon <[email-masked]>
Date: Tue, 4 Sep 2018 17:16:56 -0600

Hello,

On 30/08/18 02:31 AM, Saito Takaaki wrote:
> I guess the "s" command, when "i" flag is supplied, does not work
> correctly in some cases.
> 
> Assuming the following Bash command as an example:
> 
> echo abcdefghijkl | sed 'h;G;s/\(a.*\).*\1/(\1)/i'

Thank you for reporting this issue with specific details
to easily reproduce it, and thanks to you Bill for a quick test on the
latest sed version.

I can confirm that this is an old bug in sed (technically: in gnulib)
which was fixed sometime between version 4.3 and 4.4 .

Specifically, this commit fixed the issue (by updating gnulib):
https://git.savannah.gnu.org/cgit/sed.git/commit/?id=44d99bf5c98ea77de0addf55ad7fe281396de996

In gnulib, these are updated changes and they include several
fixes to the regex/dfa code:

https://git.savannah.gnu.org/cgit/gnulib.git/log/?qt=range&q=a3fd683d..85bd3ab6

I have not tried to pin-point the exact change which fixed the issue.

> [1] sed (GNU sed) 4.4 Packaged by Cygwin (4.4-1) on Cygwin/Windows 10
> (32bit)

I don't have access to 32bit cygwin, but on 64bit cygwin (windows 7) 
with sed-4.4-1 I do not experience the bug - can you confirm it still 
happens even in sed-4.4 ?

> [2] GNU sed version 4.2.1 on Debian wheezy/sid (32bit)
> 
> [3] sed (GNU sed) 4.4.2 on CentOS 7 (64bit)
(I assume you meant sed-4.2.2 on CentOS)

Given that sed-4.2.2 is almost six years old,
and the fixed version (sed-4.4) is also already a year and a half old,
I'm inclined to close this bug as "wontfix".

CentOS-7 (and by proxy, RHEL-7) are likely the only officially supported
distributions that still use the old sed version 4.2.2.

Eric, Jim - what do you think?

regards,
  - assaf