On 01/20/2016 02:38 PM, Trek wrote: > there is no way to print the NUL byte with the echo utility
POSIX says you should use 'printf', not 'echo', if you expect to use any
\ in the arguments. That said, the man page says:
echo [-n] args...
...
\0digits
Output the character whose value is given by zero to
three
octal digits. If there are zero digits, a nul character
is output.
> with dash (XSI, no -e argument):
>
> $ dash -c 'echo \\0 | od -An -c'
> \n
So this is behavior in disagreement with the documentation, so you
definitely have discovered a bug. Of course, since POSIX already says
the use of \ is implementation-defined if XSI is not in force, and dash
doesn't necessarily strive for full XSI compliance, it might be easier
to patch the docs than to output a NUL byte.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
