Zsh Mailing List Archive
Messages sorted by:
Re: [BUG]builtin echo error doing arguments parsing
- X-seq: zsh-workers 44263
- From: Stephane Chazelas <stephane.chazelas@xxxxxxxxx>
- To: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, zsh workers <zsh-workers@xxxxxxx>
- Subject: Re: [BUG]builtin echo error doing arguments parsing
- Date: Sat, 27 Apr 2019 07:46:34 +0100
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=O22LpTB3mz0w452YwiPtAbVhtIJMxeIGn0iYlKFrjHE=; b=N+98Qxu0nffcLfGSYtu2wIdwvRlEn3YqFU0DCqiemwPUpRp+D0UdLe5frWl6O3xvKV H/W5PUJCBGrSmXkLT93ibYrMASd53AJAUkYtBrPvtjC8MW9/+qH9EPipawSt5CHDWWUv xlKVskI1EjDTp5zBxw9a+16/Hg9YFRgTnFdwckPUSUcUrvDkluXuYg8KhayT5kEFLONd BGnibw7XkL9WqzBuiuJScAoAJ5x429zeQG9NEmxBNgCYEszTJTEDIUBrGRuByXPzT4YD PH1sCUywukKVjBxO4c9lj98BvhS7LeehVRfUC7c1f3OMyAlOHe6++EgTGy/mCvBCGcxg 7BdA==
- In-reply-to: <20180224082040.GA5121@chaz.gmail.com>
- List-help: <mailto:firstname.lastname@example.org>
- List-id: Zsh Workers List <zsh-workers.zsh.org>
- List-post: <mailto:email@example.com>
- List-unsubscribe: <mailto:firstname.lastname@example.org>
- Mail-followup-to: Peter Stephenson <p.w.stephenson@xxxxxxxxxxxx>, zsh workers <zsh-workers@xxxxxxx>
- Mailing-list: contact zsh-workers-help@xxxxxxx; run by ezmlm
- References: <CGME20180222072350epcas2p3185ca17f5f0e3ad69b0a41dbf743f145@epcas2p3.samsung.com> <CAGobuLee=R-FsgX=8XBg9Q2XHm17yLU6q3QzPWCiryCeTX7Kfg@mail.gmail.com> <email@example.com> <firstname.lastname@example.org> <CAHYJk3SFx4LNz_DFBSJS1f9v8__+0N5gR9HvmhNDfvBYYx5eow@mail.gmail.com> <email@example.com> <CAHYJk3THGAxVRGepVT+eu5_oAHz6Mxv5oPe3rFQ6acaNoQ7QKg@mail.gmail.com> <firstname.lastname@example.org> <20180224082040.GA5121@chaz.gmail.com>
(full quote below for reference as that was over a year ago)
I had requested the Austin Group amend the POSIX specification
to allow for echo -e, echo -E, echo -:
But (as kind of anticipated) it looks like they will add -e and
-E, but not zsh's -
https://posix@xxxxxxxxxxxxxxxxx/p/2019-04-25 (password in
So it may be worth disabling the special handling of "echo -" in
sh emulation (and keep the rest as-is). Also, maybe add a
xpg_echo alias to no_bsd_echo for bash compatibility.
2018-02-24 08:20:40 +0000, Stephane Chazelas:
> 2018-02-22 19:34:23 +0000, Peter Stephenson:
> > On Thu, 22 Feb 2018 20:00:58 +0100
> > Mikael Magnusson <mikachu@xxxxxxxxx> wrote:
> > > I didn't try the patch but currently echo
> > > -- just outputs --, only - terminates options for echo.
> > Yes, the -- behaviour appears to be general behaviour, in fact,
> > so not something that should be changed. So indeed it's hard to
> > do this at the moment in a shell script without some kind of kludge
> > for zsh. "disable echo" and use /bin/echo might be the best bet.
> > However, I'm not really sure if that makes it less or actually more
> > useful to align with other shells (with POSIXBUILTINS) from now on...
> > it's not obvious perpetuating the need for a kludge for ever more
> > is the best bet.
> IMO, the best thing to do here is to do nothing. Leave it as it
> The fact that - marks the end of options in zsh is documented
> and relatively well known.
> That makes it one of the very few echo implementations that can
> actually output arbitrary strings reliably (the only one if you
> consider that zsh is the only shell that can store NULs in its
> echo -E - $var
> The only other modern implementation I'm aware of that can do
> that (in a Bourne-like shell) is yash's with its:
> ECHO_STYLE=raw echo "$var"
> To be POSIX compliant, echo -- *must* output --<nl> (-- as an
> end-of-option marker must *not* be supported), and support for
> -, -e and -E should be disabled. Also echo -nn should output
> However doing that would certainly break many scripts as the sh
> emulation is often used to interpret code written for bash and
> bash is also not POSIX compliant in that regard even in POSIX
> mode (unless the xpg_echo option is also enabled) as "echo -e"
> doesn't output "-e<nl>" there.
> To be UNIX compliant, no option should be recognised and -e
> should be the default.
> People already know or should already know that echo cannot be
> used for portability/reliability. It's too late to fix it and
> zsh's implementation is actually the least broken of them (for
> the very reason that it supports a way to mark the end of
> zsh does support the POSIX printf and the ksh print which have a
> more reliable and portable API (at least when limited to the
> basic usage of echo, with the caveat that print '\01234' behaves
> differently in zsh than in other ksh implementations).
> See also https://github.com/att/ast/issues/370 for ksh93, where
> they considered changing the behaviour of echo and eventually
> backed down when considering the backward compatibility risk.
> Note that pdksh was another shell that skipped "-" arguments.
> But the "-" didn't mark the end of options, it was a bug in the
> option parsing.
Messages sorted by: