Subject: Re: bug#32765: Bug when changing and adding line

From: Assaf Gordon <[email-masked]>
Date: Tue, 18 Sep 2018 16:16:03 -0600

tag 32765 notabug
close 32765
thanks

Hello,

On 18/09/18 03:55 PM, Mohamed Akram wrote:
> Given the following command:
> 
> echo foo | sed '{
> c\
> bar
> a\
> baz
> }'
> 
> GNU sed 4.4 prints:
> 
> bar
> 
> Expected (and on macOS):
> 
> bar
> baz
> 

I think (based on reading the POSIX spec) that GNU sed
is actually correct, while MacOS's sed is wrong.

The POSIX standard says about the "c" command:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html#tag_20_116_13_03

   [2addr]c\
   text
      Delete the pattern space. With a 0 or 1 address or at the end of a
      2-address range, place text on the output and start the next cycle.

That is - after executing the "c" command (and outputting "bar"),
sed should "start the next cycle" - meaning skip all other commands.

I'm thus marking this as "not a bug",
but discussion can continue by replying to this thread.

regards,
  - assaf