DASH Shell discussions
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Trek <trek00@inbox.ru>, dash@vger.kernel.org
Subject: Re: echo do not print NUL byte
Date: Wed, 20 Jan 2016 15:19:00 -0700	[thread overview]
Message-ID: <56A007D4.4000207@redhat.com> (raw)
In-Reply-To: <20160120223850.25cdf852@enterprise>

[-- Attachment #1: Type: text/plain, Size: 1008 bytes --]

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-01-20 22:19 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 21:38 echo do not print NUL byte Trek
2016-01-20 22:19 ` Eric Blake [this message]
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=56A007D4.4000207@redhat.com \
    --to=eblake@redhat.com \
    --cc=dash@vger.kernel.org \
    --cc=trek00@inbox.ru \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox