Subject: Re: [bug] shwordsplit not working on $@ when $# > 1
From: Peter Stephenson <[email-masked]>
To: [email-masked]
Date: Mon, 8 Aug 2016 19:27:34 +0100
List-Id: Zsh Workers List <zsh-workers.zsh.org>

On Mon, 8 Aug 2016 12:16:26 +0100
Stephaneo Chazelas <[email-masked]> wrote:
> It looks like the elements of $@ only undergo splitting when $#
> is 1:
> 
> ~$ zsh -o shwordsplit -c 'IFS=:; echo $@' zsh a:b
> a b
> ~$ zsh -o shwordsplit -c 'IFS=:; echo $@' zsh a:b c
> a:b c

The variable isarr from the value entry v->isarr is negative, so we
don't go into the loop that does joining and splitting as that
explicitly asks for (isarr >= 0).  (It was 0 for a scalar, hence the
first case above.)

Setting this negative is apparently deliberate:

/* "$foo[@]"-style substitution
 * Only sign bit is significant
 */
#define SCANPM_ISVAR_AT   ((int)(((unsigned int)-1)<<15))

This seems to conflict with the use of isarr in paramsubst(); that's
documented but I think only because I tried to decode the code.  I don't
know what this SCANPM_ISVAR_AT is doing.  Perhaps it needs converting to
something else at some point?

pws