From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21655 invoked by alias); 24 Feb 2018 08:21:00 -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: 42396 Received: (qmail 18314 invoked by uid 1010); 24 Feb 2018 08:21:00 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f45.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(74.125.82.45):SA:0(-1.9/5.0):. Processed in 12.826911 secs); 24 Feb 2018 08:21:00 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, SPF_PASS,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.1 X-Envelope-From: stephane.chazelas@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to:user-agent; bh=1oiVbOn/fpFVaUPN7W9fEBmnIkY4TX9bwfrCt0tPu94=; b=e/A3Ob8PrGbR3/KXfT630b4Namz7NMhr3OnKcWKVTKP/chKUSW+PLz0Bt+9QintcZU RSYvvhW519fP/Wl31zf6/3afqxSpeLZZNCQI5hqqoM0oj2gu8R9y5ib6Aj6xvndU7IZD n2RWUEbGLd3VpiUDnQF3a+5hOmKl5u2yHvniRkgEJcYEibhaB6T+3v625i13JukCEzFR itkGNfjEDB+vZdDIkBOBHKfbi+dvXVIoVUCDaBmEVUdUUTdnTa6MsP8LBGVOVdA7iTOu dnXWM9KpXtO9Dy/SAusx60UacMbN/ZFGs4LaIThSQ0T01uV8tz37XHkmJ16wIURAP69P S7KQ== 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:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to:user-agent; bh=1oiVbOn/fpFVaUPN7W9fEBmnIkY4TX9bwfrCt0tPu94=; b=J3vrKAzRaT3nepuq93MrmuYEF6A6TckvBn587SqFOPt8heAoOKM6zHYQMyzGiyd8Xl dHfI8bxIk8zf1EyfZgJspTc24tUzcQ67W8s5/MGGS4eQRDx/tuPiEA/z1bh7RPYpPMHx KDQkdnbljyZ4amVkHMkewHXeZ4kYwattaSMOb4KCu2W2+gDYbqLoa/REbMfwE711Rwct FxuuiI7DX+LdlmhKQREP6k++/y57kUgHLpHZIH0+pr7GBVsMKNo6UAEoAvc2yjWGz108 jPD1BB/h4Nenhza5e92vbgj2dEhZAIuzhUxoG22KII4GO/94horkySPfXC4aY16/itZk afFQ== X-Gm-Message-State: APf1xPAiym7rijEQnl4jY+Ys2LiEuZmqyT7YIvzk2dSlAIUXzhqkIQer 0S7Xnqk6ZQfOkg7PphsdiMeP5w== X-Google-Smtp-Source: AH8x226OkQofzR/MgJmFqllxJYcvEN4+ISLtNx/wn4gmNs95oTo8PV8iu6LC2oMIX+cV18hLJmy9Qg== X-Received: by 10.28.165.7 with SMTP id o7mr3311132wme.38.1519460442837; Sat, 24 Feb 2018 00:20:42 -0800 (PST) Date: Sat, 24 Feb 2018 08:20:40 +0000 From: Stephane Chazelas To: Peter Stephenson Cc: zsh workers Subject: Re: [BUG]builtin echo error doing arguments parsing Message-ID: <20180224082040.GA5121@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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180222193423.16d0bf46@ntlworld.com> User-Agent: Mutt/1.5.24 (2015-08-30) 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. -- Stephane