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.
* Daniel Kahn Gillmor <dkg@fifthhorseman.net>, 2025-05-20 13:20: FWIW, printf is not a builtin in posh: $ posh -c 'printf --version | head -1' printf (GNU coreutils) 9.1
Ah, thanks for that clarification. At any rate, I can work around what i was trying to do by using octal escape sequences, which are mandatory in POSIX shell, and supported by all the printf implementations i've looked at. But hex escape sequences are much nicer and very widely supported, so it would be nice if dash could support them too.