Subject: bug#21416: "--" syntax for ignoring flags doesn't seem to work right with GNU /bin/echo

From: Eric Blake <[email-masked]>
Date: Fri, 4 Sep 2015 16:05:49 -0600

On 09/04/2015 01:30 PM, Robert "Finny" Merrill wrote:
> unicasting so it doesn't reopen the bug:

[re-adding the list with permission]
The bug-tracker is perfectly fine with adding additional comments even
to a closed bug; merely replying doesn't reopen a bug report.

> 
> If POSIX says not to recognize "--" doesn't "not recognize" mean it
> shouldn't do anything at all? In that case, you're not actually
> following it since -- causes different behavior :)

You've quoted incomplete context, which changed the meaning.

>> 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."

It's not "shall not be recognized [ever]", but "shall not be recognized
in the manner [common to most utilities].  The very next phrase says
that it "shall be recognized as a string operand".

Or put another way, as a special case for the 'echo' utility, '--' shall
be treated the same as any other argument, and always be output
literally, rather than being recognized as the special elided
end-of-options marker, because 'echo' does not understand options (at
least when POSIX rules are in effect).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org