dash.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* echo do not print NUL byte
@ 2016-01-20 21:38 Trek
  2016-01-20 22:19 ` Eric Blake
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Trek @ 2016-01-20 21:38 UTC (permalink / raw)
  To: dash

there is no way to print the NUL byte with the echo utility

with an XSI shell (mksh, posh, yash):

  $ sh -c 'echo \\0 | od -An -c'
    \0  \n

with a shell that requires echo -e (ksh, bash, busybox, mksh):

  $ sh -c 'echo -e \\0 | od -An -c'
    \0  \n

with dash (XSI, no -e argument):

  $ dash -c 'echo \\0 | od -An -c'
    \n

where others characters are correctly printed:

  $ dash -c 'echo \\0100 | od -An -c'
     @  \n

with dash it only works with printf:

  $ dash -c 'printf \\0\\n | od -An -c'
    \0  \n


I discovered this bug developing a small shell library, where you can
find an use case in the n_bytes_encode function of the lib/bytes.sh file
included in http://www.trek.eu.org/devel/naive/naive-0.0.2.tar.gz

c-ya!

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2016-01-21  7:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-01-20 21:38 echo do not print NUL byte Trek
2016-01-20 22:19 ` Eric Blake
2016-01-20 22:32 ` Harald van Dijk
2016-01-21  1:40   ` Trek
2016-01-21  7:18 ` Bastian Bittorf

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).