I've stumbled across a few oddities with the parsing of \0 and \x in the main argument to zsh's builtin `echo`. Consider the following: ```sh $ /bin/echo -en '\0 ' | xxd -p 0020 $ /bin/sh -c "echo -en '\0 ' | xxd -p" 0020 $ /bin/bash -c "echo -en '\0 ' | xxd -p" 0020 $ /bin/zsh -c "echo -en '\0 ' | xxd -p" 00 $ /bin/zsh --emulate sh -c "echo -en '\0 ' | xxd -p" 00 $ /bin/zsh --emulate bash -c "echo -en '\0 ' | xxd -p" 00 $ /bin/zsh -c "echo -en '\0 ' | xxd -p" 00 $ /bin/zsh -c "echo -en '\0 ' | xxd -p" 00 $ /bin/zsh -c "echo -en '\0 ' | xxd -p" 0020 $ /bin/zsh -c "echo -en '\0_' | xxd -p" 005f $ /bin/zsh -c "echo -en '\0x' | xxd -p" 00 $ /bin/zsh -c "echo -en '\x0 ' | xxd -p" 0020 $ /bin/zsh -c "echo -en '\x ' | xxd -p" 00 $ /bin/zsh -c "echo -en '\xx' | xxd -p" 0078 ``` This behavior is perplexing to me, and I can't find it documented very clearly. I feel like at least the documentation and the --emulate behavior could be improved. In terms of POSIX compliance, the [spec] doesn't go into much detail, but surely it's implied that ' ' and 'x' characters should not be parsed as part of an octal number. What do you think? [spec]: https://pubs.opengroup.org/onlinepubs/9799919799/utilities/echo.html
Attachment:
signature.asc
Description: This is a digitally signed message part