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

bugzilla-noreply at freebsd.org bugzilla-noreply at freebsd.org
Sat Oct 12 03:04:24 UTC 2019


https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=241206

            Bug ID: 241206
           Summary: sed "a" command issued on the command-line doesn't
                    append a newline
           Product: Base System
           Version: 12.0-RELEASE
          Hardware: Any
                OS: Any
            Status: New
          Severity: Affects Some People
          Priority: ---
         Component: bin
          Assignee: bugs at FreeBSD.org
          Reporter: freebsd at tim.thechases.com

To reproduce:

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

Expected results (for comparison, gsed produces this output):

    1
    one point five
    2

Actual results

    1
    one point five2

If the command is put in a script, it works as expected (though there's also a
newline as the last character of the script)

    $ cat example.sed
    a\
    one point five
    $ jot 2 | sed -f example.sed
    1
    one point five
    2

Attempts to manually add a newline

    $ sed '/1/a\
    > one point five\
    > ' input

work for BSD `sed` but then end up adding an extra newline if the same command
is issued on a Linux box where sed==gsed.

The same also holds for the "c" and "i" commands.

As I understand it, the solution would involve noticing that an a/c/i command
originates on the command-line and tacking on the extra newline at the end of
the provided data.

(side note: tested in OpenBSD too and got the same results as FreeBSD)

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


More information about the freebsd-bugs mailing list