Skip to content

l command uses different escape format than GNU #249

Open

Description

@sylvestre

Rust (incorrect format)

  $ echo "cÃ🧰y" | cargo run --quiet -- -e 'l'
  # Output: c\u00C3\U0001F9F0y$
  # (Uses \uXXXX and \UXXXXXXXX Unicode escape format)
  # Exit code: 0

GNU (correct format)

  $ echo "cÃ🧰y" | /usr/bin/sed -e 'l'
  # Output: c\303\203\360\237\247\260y$
  # (Uses \XXX octal escape format)
  # Exit code: 0

Bug Found by Fuzzer

Activity

  1. e-kwsm commented on Jan 27, 2026

    @e-kwsm
    Contributor

    https://pubs.opengroup.org/onlinepubs/9799919799/utilities/sed.html

    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. Non-printable characters not in that table shall be written as one three-digit octal number (with a preceding <backslash>) for each byte in the character (most significant byte first).

    BSD thinks à and 🧰 are printable under UTF-8:

    sed LANG output
    GNU C c\303\203\360\237\247\260y$
    GNU en_US.UTF-8 c\303\203\360\237\247\260y$
    BSD C c\303\203\360\237\247\260y$
    BSD en_US.UTF-8 cÃ🧰y$
    uutils C c\u00C3\U0001F9F0y$
    uutils en_US.UTF-8 c\u00C3\U0001F9F0y$

    But anyway Unicode escaped string is not compliant with POSIX.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions