From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 6721 invoked by alias); 25 Mar 2018 06:43:01 -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: 42526 Received: (qmail 8534 invoked by uid 1010); 25 Mar 2018 06:43:01 -0000 X-Qmail-Scanner-Diagnostics: from mail-wm0-f47.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.47):SA:0(-1.9/5.0):. Processed in 1.284615 secs); 25 Mar 2018 06:43:01 -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, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,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=cygzrpcZZqjoWcepVYsLH8kOAG2gCrkZaEbnmIQtfqk=; b=g5MxrCRDo2pFNJAv9rqZDViH3N/TGkZhLpQzte/OD/pcZsMldz5oYNDMyJCDKvoLcp fQLB4xa2eBpc7rP5HMxVCr5+z66+6mI/7o8tQ8fmGn/hX/Q2BJvXutAzN+Mxih3xj/07 83rg+RoHc9RWQUvHfCKqBl1AFW7Mke3RZQjA5PJtDJpCDvF1mnHYHdHfSFdEwf21mwjE UmXCzQxWNL1LP5G5dKtFXsd6M5PXB8nLAXsqjbiQ74RhjirPJOw74xvqB4tlv8jkiZv6 czjKlAaFkLQwI7354Sk7v4dRfhXRf+YiJFrxh47b7O66D7efg6zB/0vfIlcTscS+lj0Z rCuw== 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=cygzrpcZZqjoWcepVYsLH8kOAG2gCrkZaEbnmIQtfqk=; b=Q3fgxSfEuPDFIfHKWbucncNGz0+o/QCVMtJ7cXLrDlPe31rvVznOeEak9IlT50mtHP UttbzaPIZpxFquQfO7arP1VbQYO/jWNjRrAY1knIt/fUPjWjs0B++Mx0wRRV+5pFkMmk BvCNwnaex1UanhWmkA/rhCq9heZHbEcmRM7XymlDOqXxZRRkNGst8hv79Qee71SN7Zbc u/VcHR8uNKRaP7rwblSlZgJXnrDuYGDhncv5euJRNu/5c+N77NrWMUCMVGDXb/o5Or7K INlsDzZWKD3CGDAIFGiH40TBQuCnaQYKzD3IebX5EO0HDsUzou8aK3d89MnfL/9SlIJa jDag== X-Gm-Message-State: AElRT7Eu88u26uNXqTDRsuI+tPdbjUtf6yyfgxJKi/ffVOz1WbLn+xLK QX1UkoobyUxQO3VO2oEDaKWdjg== X-Google-Smtp-Source: AG47ELsDrBuCPpFUZFTctHC3vwbqQJi6NxLn5Z5vonAd2d/FZocBlCyrYqXWrGHDtqEakfpQ7wYE4Q== X-Received: by 10.28.153.75 with SMTP id b72mr13156259wme.127.1521960176347; Sat, 24 Mar 2018 23:42:56 -0700 (PDT) Date: Sun, 25 Mar 2018 07:42:54 +0100 From: Stephane Chazelas To: Martijn Dekker Cc: zsh-workers@zsh.org Subject: Re: [doc] "sh_word_split nothing to do with word splitting"? Message-ID: <20180325064254.GA5782@chaz.gmail.com> Mail-Followup-To: Martijn Dekker , zsh-workers@zsh.org References: <20180311094458.GA6450@chaz.gmail.com> <180311112407.ZM2303@torch.brasslantern.com> <20180311205348.GC6450@chaz.gmail.com> <20180312074329.GA6416@chaz.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) 2018-03-24 21:17:48 +0100, Martijn Dekker: > Op 12-03-18 om 08:43 schreef Stephane Chazelas: > > I'd rather zsh keep it that way as a statement of resistance > > against silliness, at least until someone complains that his > > POSIX script fails when run on zsh because its arithmetic > > expansions are not split as expected. > > The thing is, there are very good reasons for that silliness, and for > not resisting it in sh emulation. > > In a way, POSIX is primarily descriptive, not prescriptive. It intends > to incorporate the historical practice that real-world shell > implementations have copied into the standard, so that everyone can be > compatible with it. > > For the most part, that historical practice was established by AT&T > ksh88. It's mostly obsolete now but very much lives on in all the shells > that copy its behaviour. [...] There have been many cases where POSIX have specified accidents of implementation or design bugs of original implementations and the POSIX specification has been fixed later on when spotted even in some cases forcing the original implementation to be fixed. IMO, here, it's clearly one of those. The solution here is not to implement the bug but fix the specification. > ksh88 implemented the original shell arithmetic expansion. It subjects > those expansions to IFS field splitting. > > Not emulating this in zsh's sh emulation mode will probably not cause > many scripts to fail on zsh-as-sh. However, someone could use zsh to > develop a POSIX script intended to be compatible with other shells. > > And that someone might end up under the mistaken impression that it's > pointless to quote arithmetic expansions. Cue potential mysterious > breakage on non-zsh shells. There are many "unspecified areas" in POSIX where it's the case, if you rely on unspecified behaviour you can't expect anything portably. Here I would expect POSIX, when fixed would at first leave the behaviour unspecified to allow both the bogus historical behaviour and the zsh behaviour (which until not so long ago was the behaviour of most other shells, it's quite sad to see that many have broken their shell to meet POSIX compliance), maybe with a "future direction" requiring the zsh behaviour. In the mean time, we should document the difference so it's no longer "mysterious" like in my suggested patch. > That's why I believe it's important that this is fixed in sh emulation. > > > pdksh was not doing word/field splitting there and posh and > > OpenBSD sh still don't. > > Then pdksh, supposedly a ksh88 clone, failed to clone ksh88 in that > aspect -- among many others. [...] pdksh has fixed a number of issues in ksh88 (itself broken on many aspects as you've found out) as well. Another one shared with zsh: that the ".*" glob does not include "." nor ".." (in the case of pdksh actually inherited from the Forsyth shell). That also breaks POSIX compliance, though last time I mentioned it on the Austin Group mailing list, they would likely be willing to change the spec to allow it (POSIX already leaves it undefined if readdir() returns those IIRC). Another example is brace expansion (also supported by zsh and bash) which also breaks POSIX compliance which was not in ksh88, added in pdksh (1992), and then later in ksh93. -- Stephane