Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > gnu.bash.bug > #16759

Re: echo builtin doesn't handle end-of-options flag

From Eli Schwartz <eschwartz@archlinux.org>
Newsgroups gnu.bash.bug
Subject Re: echo builtin doesn't handle end-of-options flag
Date 2020-08-16 12:26 -0400
Message-ID <mailman.2308.1597595182.2739.bug-bash@gnu.org> (permalink)
References <F122E6E9-6067-45EF-8D18-2B1EBF0D5917@codegnome.org> <737d2184-8b59-0eee-4c56-41f7a67d8f88@redhat.com> <ec2197fd-a742-00b6-ebf6-6a3a217510f4@archlinux.org>

Show all headers | View raw


[Multipart message — attachments visible in raw view] - view raw

On 8/16/20 12:21 PM, Eric Blake wrote:
> On 8/16/20 10:47 AM, Todd A. Jacobs wrote:
> 
>> Description:
>>          The echo builtin accepts options, but does not seem to handle
>>          `--` correctly as the end of options.
> 
> The correct behavior for echo is described here:
> https://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."
> 
>> The expected behavior
>>          would be for -- to be removed, and any following flag-like
>>          substrings printed as-is.
> 
> Your expectations are wrong, they contradict what POSIX says.
> 
>>
>> Repeat-By:
>>          echo "-n"         # "" but expecting "-n"
> 
> POSIX says this one is implementation-defined; so whether -n is treated
> as an option or as a string to echo has to be documented by the
> implementation (bash documents treating it as an option).

Err...

"Implementations shall not support any options."

>>          echo -- -n foo    # -- -n foo
> 
> POSIX says this has to output '-- -n foo' and a newline. -n wasn't
> first, so you no longer have the implementation-defined behavior, but
> well-defined.
> 
>>          echo -- "-n foo"  # -- -n foo
> 
> Also well-defined.
> 
> I see nothing in your report about bash disobeying POSIX, but rather
> confusion on your part about what POSIX actually requires.

bash does disobey POSIX, but not in the manner which the report specifies.

-- 
Eli Schwartz
Arch Linux Bug Wrangler and Trusted User

Back to gnu.bash.bug | Previous | Next | Find similar


Thread

Re: echo builtin doesn't handle end-of-options flag Eli Schwartz <eschwartz@archlinux.org> - 2020-08-16 12:26 -0400

csiph-web