[Bug 279223] sed - "a\" comand displays different results depending on use of -e option

From: <bugzilla-noreply_at_freebsd.org>
Date: Wed, 22 May 2024 16:13:18 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=279223

--- Comment #1 from Eric <erichanskrs@gmail.com> ---
Using 13.3-RELEASE and "pkg install gsed" (version 4.9).

For the a\ command of sed(1), whether or not specifying the -e option, produces
different results.
sed ' ... ' (without the -e option) seems to be in error.

        $ cat t
        1
        2
        $ cat sed-add.sh
        #!/bin/sh
        sed '/1/a\
        -new line-' <t

        printf "\n>> sed -e '... '\n"
        sed -e '/1/a\
        -new line-' <t
        $ sh sed-add.sh
        1
        -new line-2

        >> sed -e ' ... '
        1
        -new line-
        2

Using variants with double quotes, as in:
        sed "/1/a\\
        -new line-" <t
display the same differences.

gsed behaves as FreeBSD sed -e ' ... '

I couldn't find any specific POSIX guidance at:
https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html
but the behaviour of sed -e ' ... ' seems the correct one.

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