From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 22921 invoked by alias); 12 Mar 2018 07:43:38 -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: 42450 Received: (qmail 25996 invoked by uid 1010); 12 Mar 2018 07:43:38 -0000 X-Qmail-Scanner-Diagnostics: from mail-wr0-f175.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(209.85.128.175):SA:0(-1.9/5.0):. Processed in 1.888841 secs); 12 Mar 2018 07:43:38 -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_H2,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=cXdnr2fbvnqZKzNoWAHOvFIeD8YDU0N7SJGir1EFr1k=; b=WIauePdDb4pWxZ7Kmz5cigbHYDVEJaep0NHkGwCOjHTELcsouMrNCcPK5q1hZhhNK4 MeyMFNMooLFhVpYsaBh1C+Ia6x1VdJ6D8S/7qF82ys9dBqrZ7V9xAmEML5nKIxNTl1Oy cNzaPROicA8XUtWgbEslCvvgrSeUXySwojMH7ZuSXzao5GEFmE+MxMs7qbbLyNQ31/Xa 4ecvbS8R6KRO9UT1UXWmzutfMDXxIWzMgqSeMMwscTTJeKL8CGzlFIkNC+YIggfxU65A 5nld4mPbA1kzSEjErJO1b+U0L5TCNPNYD4lY1FMxHRP22/XIEmocFmkeXYXMTeJYrrV1 o2Bg== 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=cXdnr2fbvnqZKzNoWAHOvFIeD8YDU0N7SJGir1EFr1k=; b=QxGyNE2xBGMgYP9cC3DBhE/ISakl+gVUCV0CAUt70wRH4BjDQCYGfEnMUQ8tBf/K+y dF/U4KDishYnKVp7PTG52flY6YNeJsrCTmKjV/2gV2SmJ3Y687xMJqMlljdvlPJMf056 oGz+EylJvUn2bedrtSTU8SkUJpPOyWWngvNYEnec6zoGhITAypptczwAgx24L7O5CWMV xx+vGAzKvGDQ6+J3KtlMNvxaLij1H8c97mgtjMqrjI5NRVvgWHnXYWp6W5z+XUCBd18A GaT0zw5ax4pxI+ekQ5l2mnC5jIpWFqzBTeb8m9A1fMFk/QgE8SltiMO02/CNf/NyewCa Y5Hw== X-Gm-Message-State: AElRT7EIVA+oYDQD9ih2M9widdOMfhA7gFwohvCRdKxJztd//UiSHb+8 gEAzVHWXu1sI6k4WudwLHOO6Rg== X-Google-Smtp-Source: AG47ELsb6LGHeuItWV8nIGYe5n0UZVxetwbTPgPUWoULA2ivsZjSSXYxx6sOd9C2/13236CPewzi6Q== X-Received: by 10.223.162.201 with SMTP id t9mr2402343wra.148.1520840611783; Mon, 12 Mar 2018 00:43:31 -0700 (PDT) Date: Mon, 12 Mar 2018 07:43:29 +0000 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: <20180312074329.GA6416@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> 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-12 00:41:03 +0100, Martijn Dekker: > Op 11-03-18 om 21:53 schreef Stephane Chazelas: > > What about changing it to something like: > [...] > > +Causes tt($IFS) field splitting to be performed on unquoted parameter > > +expansions in addition to command substitutions. Note that contrary to > > +POSIX shells, field splitting is still not performed on unquoted > > +arithmetic expansions > > In terms of sh emulation, that's actually a bug. It may be terrible (who > would ever want to split an arithmetic expansion?), but emulation is > emulation and SH_WORD_SPLIT should cause splitting as in POSIX sh. 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. Not doing so would keep fixing scripts where authors omitted to quote arithmetic expansions in contexts where $IFS contained dashes (or digits) on the ground that no shell author in their right mind would ever want to subject arithmetic expansion to split+glob (note that no shell does split+glob upon tilde expansion nor process substitution nor $'...' expansions (though bash used to do globbing upon tilde expansion) where that wouldn't make sense *either*). pdksh was not doing word/field splitting there and posh and OpenBSD sh still don't. > > > and contrary to the Bourne shell, not on words > > +that are not the result of expansions. > > Now that even Solaris finally got rid of it, I think the ancient Bourne > shell is definitively obsolete and not worth mentioning in current > documentation. POSIX is the norm now. Agreed. I suspect the original text was making that point about "shwordsplit having nothing to do with word splitting" in reference to the Bourne shell. > > Like in other Bourne-like shells, > > I'd say "Like in other POSIX shells,". Except that zsh (like many other Bourne-like shells) is not strictly speaking fully compliant (though on several aspects is more compliant in sh emulation than some certified ones like the /usr/xpg4/bin/sh of Solaris) > [...] > > Not sure it's worth mentioning: > > > > $var() function-definition > > > > as a context where shwordsplit happens. > > It might be better if the possibility to define functions by names > resulting from expansions were disabled completely if SH_WORD_SPLIT is > active, so the program fails properly instead of producing weird/broken > behaviour. > > Alternatively, SH_WORD_SPLIT could be ignored in that context. [...] AFAIK, that's a feature which is actually used in some of the functions shipped with zsh to declare several functions at once with the same body. It's not a POSIX conformance issue as the behaviour is unspecified there for: $var() { ...; } As $var is not a valid function name. In any case, I wouldn't expect anyone to use SH_WORD_SPLIT for anything but to interpret POSIX/ksh scripts (via "emulate sh/ksh") which wouldn't have such constructs, so I don't expect it would cause any problem. On the other hand, one might still want to do: $=myfunctions() { something; zle .$WIDGET; } for instance, that is using the explicit word-split operator to define several functions at once. -- Stephane