Path: csiph.com!fu-berlin.de!usenet.stanford.edu!not-for-mail From: Eric Blake Newsgroups: gnu.bash.bug Subject: Re: echo builtin doesn't handle end-of-options flag Date: Sun, 16 Aug 2020 11:30:59 -0500 Organization: Red Hat, Inc. Lines: 29 Approved: bug-bash@gnu.org Message-ID: References: <5f4dda03-d3fb-1a23-d0a9-925a9def4459@archlinux.org> <58fb8ab0-733b-af68-4931-6078b4d8f671@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 1597595471 6302 209.51.188.17 (16 Aug 2020 16:31:11 GMT) X-Complaints-To: action@cs.stanford.edu To: Eli Schwartz , 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=1597595465; 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=kFudGQghEofAnzSIVJUBevrN+W2hFkwfNywk5J+4oIs=; b=I09VdKJBp2/JPzuqXMTdlYQwzJJtqSssXbTxiVnOhlmigogDaaeEDmzkSknvywfryjmcOW ET0VhUZoxy0iTgSsXBCYvEiKHYtwDSKj5+MMbFafOgoglT6aFiZ4a+jjwZ7Jq0LT5zvwcn aoyO3Gc9TnlhQtzodADLEoFod3Tgb4I= X-MC-Unique: ZcTZwFROOumeg8GDhPMfQQ-1 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 In-Reply-To: <5f4dda03-d3fb-1a23-d0a9-925a9def4459@archlinux.org> Content-Language: en-US X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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=207.211.31.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:31:05 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 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Mailman-Original-Message-ID: <58fb8ab0-733b-af68-4931-6078b4d8f671@redhat.com> X-Mailman-Original-References: <5f4dda03-d3fb-1a23-d0a9-925a9def4459@archlinux.org> Xref: csiph.com gnu.bash.bug:16760 On 8/16/20 11:20 AM, Eli Schwartz wrote: > https://pubs.opengroup.org/onlinepubs/9699919799/utilities/echo.html > > echo does not accept options, and is not permitted to accept options > including "--". > > bash does accept -n, -e, -E in violation of POSIX, unless shopt -s shopt > -s xpg_echo is set, but it doesn't implement -- and I don't really see a > justification to do so. Not quite: https://www.austingroupbugs.net/view.php?id=1222 says that accepting -e and -E will become acceptable in the next revision of POSIX (accepting -n was already acceptable on non-XSI systems). > Either enable xpg_echo or use printf. POSIX recommends using printf. My personal recommendation is to avoid xpg_echo except when trying to break things - there are a number of what claim to be bash scripts that are not aware of the effects of xpg_echo and which operate incorrectly when you actually set it; whereas using printf is reliably portable. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org