All of lore.kernel.org
 help / color / mirror / Atom feed
From: Trek <trek00@inbox.ru>
To: dash@vger.kernel.org
Subject: echo do not print NUL byte
Date: Wed, 20 Jan 2016 22:38:50 +0100	[thread overview]
Message-ID: <20160120223850.25cdf852@enterprise> (raw)

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!

             reply	other threads:[~2016-01-20 21:39 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 21:38 Trek [this message]
2016-01-20 22:19 ` echo do not print NUL byte Eric Blake
2016-01-20 22:32 ` Harald van Dijk
2016-01-21  1:40   ` Trek
2016-01-21  7:18 ` Bastian Bittorf

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20160120223850.25cdf852@enterprise \
    --to=trek00@inbox.ru \
    --cc=dash@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.