zsh-workers
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: Martijn Dekker <martijn@inlv.org>, zsh-workers@zsh.org
Subject: Re: [doc] "sh_word_split nothing to do with word splitting"?
Date: Mon, 12 Mar 2018 08:07:27 +0000	[thread overview]
Message-ID: <20180312080727.GB6416@chaz.gmail.com> (raw)
In-Reply-To: <20180312074329.GA6416@chaz.gmail.com>

2018-03-12 07:43:29 +0000, Stephane Chazelas:
[...]
> 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*).
[...]

Also note that zsh arithmetic expansions may output globs
(though the extendedglob + emulate sh + [#base] is an unlikely
combination):

/dev/fd$ ARGV0=sh zsh -o extendedglob -c 'a=$(([#8]8)); echo $a'
10

(8#10 expanded to 10 as # is an extendedglob operator and
there's a "10" file in /dev/fd).

POSIX also requires the result of arithmetic expansions to be
subject to globbing though of course it doesn't really apply in
POSIX scripts except maybe in things like [0$((-3))]

So if zsh was made POSIX compliance in that regard,
echo $(([#8]8)) would expand to 10 in that context above.

-- 
Stephane


  reply	other threads:[~2018-03-12  8:07 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-03-11  9:44 Stephane Chazelas
2018-03-11 18:24 ` Bart Schaefer
2018-03-11 20:53   ` Stephane Chazelas
2018-03-11 23:41     ` Martijn Dekker
2018-03-12  7:43       ` Stephane Chazelas
2018-03-12  8:07         ` Stephane Chazelas [this message]
2018-03-16 17:26           ` Stephane Chazelas
2018-03-16 18:28             ` Bart Schaefer
2018-03-16 19:33               ` Stephane Chazelas
2018-03-24 20:17         ` Martijn Dekker
2018-03-25  6:42           ` Stephane Chazelas
2018-03-26 18:11             ` Martijn Dekker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180312080727.GB6416@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=martijn@inlv.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).