[Bug 241206] sed "a" command issued on the command-line doesn't append a newline

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 15 Dec 2021 20:55:34 UTC

jwdevel@gmail.com changed:

           What    |Removed                     |Added
                 CC|                            |jwdevel@gmail.com

--- Comment #1 from jwdevel@gmail.com ---
I'm not sure this is a bug, just a difference in behavior between GNU sed and
BSD sed (of which there are many).

The docs for 'a' in "man 1 sed" say: "Write text to standard output immediately
before each attempt to read a line of input". In my reading of that, since
"text" does not contain a newline, neither does the output.

You probably already know this, but this works in both cases:

    $ jot 2 | sed '/1/a\
    > one point five
    > '

(That is, type the extra newline in your shell, before adding the terminating
single-quote. This is the same as in your script example.)

Though that might technically run afoul of GNU sed's documentation, which says
"Append text, which has each embedded newline preceded by a backslash."
I just put a raw newline there, not preceded by backslash.

It does work though, regardless.

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