[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#13899: Bugs in echo and printf
From: |
Eric Blake |
Subject: |
bug#13899: Bugs in echo and printf |
Date: |
Thu, 07 Mar 2013 15:29:08 -0700 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130219 Thunderbird/17.0.3 |
tag 13899 notabug
thanks
On 03/07/2013 02:57 PM, Sérgio Coutinho wrote:
> Hello!
>
> I discovered a few bugs in echo and printf.
>
> echo --help
> echo --version
> printf --help
> printf --version
>
> They all don't work...
Thanks for the report. However, without telling us what you saw vs.
what you were expecting, it's hard to guess what you saw, or why you
think that what you saw is wrong. Furthermore, I suspect this is
misunderstanding on your part, rather than an actual bug in coreutils.
First, are you sure you were even testing coreutils' binaries, or were
you testing the builtins that ship as part of your shell? For these two
binaries, you are best off running 'env echo' or 'env printf' if you
want to ensure that you are running the executable that coreutils
installed into your PATH rather than your shell's version.
Second, the behavior we have is intentional:
By default, coreutils' echo produces useful messages, even though this
violates POSIX:
$ env -u POSIXLY_CORRECT echo --help | tail -n1
For complete documentation, run: info coreutils 'echo invocation'
$ env -u POSIXLY_CORRECT echo --version | head -n1
echo (GNU coreutils) 8.17
You can bypass these messages by asking for POSIX compliance, so that
our hands are tied and we output a literal string:
$ env POSIXLY_CORRECT=1 echo --help
--help
$ env POSIXLY_CORRECT=1 echo --version
--version
Meanwhile, for printf, our behavior of useful messages is an extension
permitted by POSIX, so POSIXLY_CORRECT has no impact on operation:
$ env printf --help | tail -n1
For complete documentation, run: info coreutils 'printf invocation'
$ env printf --version | head -n1
printf (GNU coreutils) 8.17
And again, you can bypass these messages with the POSIX-mandated syntax:
$ env printf -- --help
--help
$ env printf -- --version
--version
As such, I'm closing this bug report, although you can feel free to add
further comments or questions.
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature