From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.1 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id 5982651d for ; Sat, 27 Apr 2019 06:47:32 +0000 (UTC) Received: (qmail 25004 invoked by alias); 27 Apr 2019 06:47:16 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 44263 Received: (qmail 12978 invoked by uid 1010); 27 Apr 2019 06:47:16 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm1-f43.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.101.1/25426. spamassassin: 3.4.2. Clear:RC:0(209.85.128.43):SA:0(-2.0/5.0):. Processed in 3.527917 secs); 27 Apr 2019 06:47:16 -0000 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.128.43 as permitted sender) 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== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:subject:message-id:mail-followup-to :references:mime-version:content-disposition:in-reply-to:user-agent; bh=O22LpTB3mz0w452YwiPtAbVhtIJMxeIGn0iYlKFrjHE=; b=bGnWNbKYfJcIf/8g0XzWLocg4SVPN20+99RnnLsDyPaKHTmOba5Ymtd6kXtD+xLtyu 1QzkkIaXhM/1OahIEk6q4aWvAnbNzmKjaK5cZR7uKTUSSMJS1kbfvrTmjU4LCy7ED6TV knW40JDZe3MIfiIwgEkkzFkbZ5kOnX4CIz5agBmL0mzAPZ0DiONfNklbx0BrHZ3bjvzO nOVJsRSAcxXk9ovRdWshJ74Yv4eWitL+roIAcoVeqfL6bYNTiIXigC57t7uGpR3fceKp NKTM4hhEXQy53e1WnDJNqNPaouo8geajQYibtFak/Sm/tmlh6JAky0OtTIYDIwiG46lA l7pg== X-Gm-Message-State: APjAAAUotMdVRvzBLrNKKOsezqD2IYBy0KrafcBLb501faF0VFv+H0dr qWOGlN9X5YiAoWWtZqu/Tgw= X-Google-Smtp-Source: APXvYqw1FYN9usr538l+3Rfq3M//1TzaroAlSq4QrRNH/sZWdCdM+b8ecRCV+uyeaO7KjhNMZxa+NQ== X-Received: by 2002:a1c:a7c2:: with SMTP id q185mr10839174wme.75.1556347597017; Fri, 26 Apr 2019 23:46:37 -0700 (PDT) Date: Sat, 27 Apr 2019 07:46:34 +0100 From: Stephane Chazelas To: Peter Stephenson , zsh workers Subject: Re: [BUG]builtin echo error doing arguments parsing Message-ID: <20190427064634.jvsvmdr7edxyz3mk@chaz.gmail.com> Mail-Followup-To: Peter Stephenson , zsh workers References: <20180222093711.0777e602@pwslap01u.europe.root.pri> <20180222103201.314c839b@pwslap01u.europe.root.pri> <20180222172601.2b7cb68b@pwslap01u.europe.root.pri> <20180222193423.16d0bf46@ntlworld.com> <20180224082040.GA5121@chaz.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180224082040.GA5121@chaz.gmail.com> User-Agent: NeoMutt/20171215 (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 -: http://austingroupbugs.net/view.php?id=1222 But (as kind of anticipated) it looks like they will add -e and -E, but not zsh's - http://austingroupbugs.net/view.php?id=1222#c4373 https://posix@posix.rhansen.org/p/2019-04-25 (password in https://www.mail-archive.com/austin-group-l@opengroup.org/msg03909.html) 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. -- Stephane 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 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 > is. > > The fact that - marks the end of options in zsh is documented > and relatively well known. > > See > https://unix.stackexchange.com/questions/65803/why-is-printf-better-than-echo > > 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 > variables) > > 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 -- (-- as an > end-of-option marker must *not* be supported), and support for > -, -e and -E should be disabled. Also echo -nn should output > -nn. > > 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" 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 > options).. > > 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.