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


Groups > gnu.bash.bug > #16757

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

Path csiph.com!2.eu.feeder.erje.net!feeder.erje.net!goblin1!goblin.stu.neva.ru!usenet.stanford.edu!not-for-mail
From Eric Blake <eblake@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: echo builtin doesn't handle end-of-options flag
Date Sun, 16 Aug 2020 11:21:23 -0500
Organization Red Hat, Inc.
Lines 45
Approved bug-bash@gnu.org
Message-ID <mailman.2305.1597594895.2739.bug-bash@gnu.org> (permalink)
References <F122E6E9-6067-45EF-8D18-2B1EBF0D5917@codegnome.org> <737d2184-8b59-0eee-4c56-41f7a67d8f88@redhat.com>
NNTP-Posting-Host lists.gnu.org
Mime-Version 1.0
Content-Type text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding 7bit
X-Trace usenet.stanford.edu 1597594896 5971 209.51.188.17 (16 Aug 2020 16:21:36 GMT)
X-Complaints-To action@cs.stanford.edu
To "Todd A. Jacobs" <tjacobs@codegnome.com>, bug-bash@gnu.org
Envelope-to bug-bash@gnu.org
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597594889; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JamWoUhkGIF9wET6JrepIJenWHc2yLktEK86T45tvAA=; b=YqOANB/Hi0+wBMwE8ipUAETnexvDu+KJ7QQZxUbNwwKa0Dk3xYxga3HFOwfP0KNeuEBRfZ pSh5iCCYZr1IwOm9DJoKPRFCFTacUxvpcqc5X+EwI3FIBKGOXCd7+EWYLyfL7+d14OGuhr 4DSyR66I7zT7OzNCAcyympI3vhHAfX0=
X-MC-Unique CiMHniRTPYWYhv-TRS29ig-1
User-Agent Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0
In-Reply-To <F122E6E9-6067-45EF-8D18-2B1EBF0D5917@codegnome.org>
Content-Language en-US
X-Scanned-By MIMEDefang 2.79 on 10.5.11.15
Authentication-Results relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@redhat.com
X-Mimecast-Spam-Score 0.001
X-Mimecast-Originator redhat.com
Received-SPF pass client-ip=205.139.110.120; envelope-from=eblake@redhat.com; helo=us-smtp-1.mimecast.com
X-detected-operating-system by eggs.gnu.org: First seen = 2020/08/16 12:21:29
X-ACL-Warn Detected OS = Linux 2.2.x-3.x [generic] [fuzzy]
X-Spam_score_int -30
X-Spam_score -3.1
X-Spam_bar ---
X-Spam_report (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, URIBL_BLOCKED=0.001 autolearn=ham autolearn_force=no
X-Spam_action no action
X-BeenThere bug-bash@gnu.org
X-Mailman-Version 2.1.23
Precedence list
List-Id Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org>
List-Unsubscribe <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe>
List-Archive <https://lists.gnu.org/archive/html/bug-bash>
List-Post <mailto:bug-bash@gnu.org>
List-Help <mailto:bug-bash-request@gnu.org?subject=help>
List-Subscribe <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe>
X-Mailman-Original-Message-ID <737d2184-8b59-0eee-4c56-41f7a67d8f88@redhat.com>
X-Mailman-Original-References <F122E6E9-6067-45EF-8D18-2B1EBF0D5917@codegnome.org>
Xref csiph.com gnu.bash.bug:16757

Show key headers only | View raw


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

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

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

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


Thread

Re: echo builtin doesn't handle end-of-options flag Eric Blake <eblake@redhat.com> - 2020-08-16 11:21 -0500

csiph-web