Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [doc] "sh_word_split nothing to do with word splitting"?



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



Messages sorted by: Reverse Date, Date, Thread, Author