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


Groups > gnu.bash.bug > #16760

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

From Eric Blake <eblake@redhat.com>
Newsgroups gnu.bash.bug
Subject Re: echo builtin doesn't handle end-of-options flag
Date 2020-08-16 11:30 -0500
Organization Red Hat, Inc.
Message-ID <mailman.2309.1597595471.2739.bug-bash@gnu.org> (permalink)
References <F122E6E9-6067-45EF-8D18-2B1EBF0D5917@codegnome.org> <5f4dda03-d3fb-1a23-d0a9-925a9def4459@archlinux.org> <58fb8ab0-733b-af68-4931-6078b4d8f671@redhat.com>

Show all headers | View raw


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

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:30 -0500

csiph-web