[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#21416: "--" syntax for ignoring flags doesn't seem to work right wit
From: |
Eric Blake |
Subject: |
bug#21416: "--" syntax for ignoring flags doesn't seem to work right with GNU /bin/echo |
Date: |
Fri, 4 Sep 2015 13:26:42 -0600 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.1.0 |
tag 21416 notabug
thanks
On 09/04/2015 12:57 PM, Robert "Finny" Merrill wrote:
> ~/workspaces/diags-dev/s1 @bs360.sjc> /bin/echo --help
> Usage: /bin/echo [SHORT-OPTION]... [STRING]...
> or: /bin/echo LONG-OPTION
> Echo the STRING(s) to standard output.
> *snip*
This is a GNU extension; it is not POSIX compliant, but can easily be
overridden, as shown below.
> ~/workspaces/diags-dev/s1 @bs360.sjc> /bin/echo -- --help
> -- --help
Thanks for the report. However, this is working as required by POSIX:
http://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html
"The echo utility shall not recognize the "--" argument in the
manner specified by Guideline 10 of XBD Utility Syntax Guidelines; "--"
shall be recognized as a string operand."
"Implementations shall not support any options."
>
> There doesn't seem to be a way to get /bin/echo to output the string "--help"
Ah, but there is:
$ POSIXLY_CORRECT=1 /bin/echo --help
--help
Also, POSIX says that 'echo' is outdated (not only because it violates
the standard syntax rules, but also because it has non-portable handling
of \), and that you should strongly consider using printf, in which
case, you would do:
$ printf -- %s\\n --help
--help
--
Eric Blake eblake redhat com +1-919-301-3266
Libvirt virtualization library http://libvirt.org
signature.asc
Description: OpenPGP digital signature
bug#21416: "--" syntax for ignoring flags doesn't seem to work right with GNU /bin/echo, Bob Proulx, 2015/09/04