[Bug 271817] sed: range change with N results in no output

From: <bugzilla-noreply_at_freebsd.org>
Date: Sun, 18 Jun 2023 22:14:52 UTC

--- Comment #3 from Andrew "RhodiumToad" Gierth <andrew@tao11.riddles.org.uk> ---
(In reply to Mohamed Akram from comment #2)

All of the pattern space (embedded newlines and all) is deleted at the end of
each cycle (after being output if appropriate).

The fact the GNU sed violates the spec is not our concern.

Your description of the "c" command is not what the spec says. The spec says
that with 2 addresses, "c" deletes the pattern space if the line is in the
addressed range, and emits the replacement text if and only if the last line of
the range is addressed. Since the "b" line is consumed by N and is never in the
pattern space at the start of the cycle, the /a/,/b/ range never sees it, so
the range extends to the last line of the file; but since you also read the
last line of the file by doing N on the second-last line, the last line is also
never processed by the "c" command so the replacement is never output.

(You seem to be assuming that the use of N does not affect addresses; that's
not what the spec says.)

You are receiving this mail because:
You are the assignee for the bug.