[Bug 287020] sed(1) l (ell) command for <backslash> not in line with man page and POSIX

From: <bugzilla-noreply_at_freebsd.org>
Date: Fri, 23 May 2025 14:30:59 UTC
https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=287020

            Bug ID: 287020
           Summary: sed(1) l (ell) command for <backslash> not in line
                    with man page and POSIX
           Product: Base System
           Version: 14.2-RELEASE
          Hardware: amd64
                OS: Any
            Status: New
          Severity: Affects Only Me
          Priority: ---
         Component: bin
          Assignee: bugs@FreeBSD.org
          Reporter: erichanskrs@gmail.com

Using 14.2-RELEASE:

For a <backslash> ("\") the sed l command*:
- does not behave according to sed(1)
- does not behave as it should as described by the POSIX text.

The following occurs:
[1-0] % /bin/echo 'n\n'| sed -n 'l'
n\n$
[2-0] % 

Expected is:
[5-0] % /bin/echo 'n\n'| sed -n 'l'
n\\n$
[6-0] %

https://man.freebsd.org/cgi/man.cgi?query=sed&apropos=0&sektion=1&manpath=FreeBSD+14.2-RELEASE&arch=default&format=html
-- relevant sed(1) text
"
Sed Functions
[...]
       [2addr]l
               (The letter ell.)  Write the pattern space to the standard out-
               put in a visually unambiguous form.  This form is as follows:

                     backslash          \\
                           [...]
"

https://pubs.opengroup.org/onlinepubs/9699919799/utilities/sed.html#tag_20_116_13_03
-- relevant POSIX text description:
"
[2addr]l
    (The letter ell.) Write the pattern space to standard output in a visually
unambiguous form. The characters listed in XBD Escape Sequences and Associated
Actions ( '\\', '\a', '\b', '\f', '\r', '\t', '\v' ) shall be written as the
corresponding escape sequence; the '\n' in that table is not applicable.
"

https://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap05.html#tagtcjh_2
-- Escape Sequences and Associated Actions:
"
    Table: Escape Sequences and Associated Actions
Escape     Represents
Sequence   Character     Terminal Action
\\         <backslash>   Print the <backslash> character.
  [...]
"
___
* Not the most spectacular find but, I ran into this, so here it is.

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