• dash: printf builtin does not interpret hexadecimal escapes \xNN

    From Daniel Kahn Gillmor@21:1/5 to Debian Bug Tracking System on Tue May 20 13:20:53 2025
    Package: dash
    Version: 0.5.12-12
    Severity: wishlist

    printf appears to typically accept escaped hexadecimal octets of the
    form \nXX, where XX are two hexdigits.

    out of several printf implementations (including /usr/bin/printf and the builtins on many other shells), dash alone simply passes those
    characters through to output:

    ```
    0 dkg@bob:~$ dash -c "printf '\xd5'" | hd
    00000000 5c 78 64 35 |\xd5|
    00000004
    0 dkg@bob:~$ bash -c "printf '\xd5'" | hd
    00000000 d5 |.|
    00000001
    0 dkg@bob:~$ posh -c "printf '\xd5'" | hd
    00000000 d5 |.|
    00000001
    0 dkg@bob:~$ zsh -c "printf '\xd5'" | hd
    00000000 d5 |.|
    00000001
    0 dkg@bob:~$ fish -c "printf '\xd5'" | hd
    00000000 d5 |.|
    00000001
    0 dkg@bob:~$ /usr/bin/printf '\xd5' | hd
    00000000 d5 |.|
    00000001
    0 dkg@bob:~$
    ```

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

    suggests that perhaps \xNN isn't a POSIX standard, so maybe it's within
    spec for dash to ignore it. But it might also be nice to make it work
    the way everyone else expects.

    --dkg

    -- System Information:
    Debian Release: 13.0
    APT prefers testing-debug
    APT policy: (500, 'testing-debug'), (500, 'testing'), (200, 'unstable-debug'), (200, 'unstable'), (1, 'experimental-debug'), (1, 'experimental')
    Architecture: amd64 (x86_64)

    Kernel: Linux 6.12.22-amd64 (SMP w/20 CPU threads; PREEMPT)
    Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8), LANGUAGE not set
    Shell: /bin/sh linked to /usr/bin/dash
    Init: systemd (via /run/systemd/system)
    LSM: AppArmor: enabled

    Versions of packages dash depends on:
    ii debianutils 5.22
    ii libc6 2.41-7

    dash recommends no packages.

    dash suggests no packages.

    -- debconf information:
    dash/ineffectivediversion:

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)