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

Re: 5.3.1-dev-0 difference in array=( "${(PA@)var_name}" )



On 14-06-2017 at 22:35:51, Bart Schaefer (schaefer@xxxxxxxxxxxxxxxx) wrote:
> On Wed, Jun 14, 2017 at 10:09 AM, Sebastian Gniazdowski
> wrote:
> > Hello,
> > % zsh-5.3.1
> > % var_name="abcdef"; array=( "${(PA@)var_name}" ); echo ${#array}
> > 1
> 
> The (A) flag doesn't mean anything in this context in 5.3.1, that was
> added about 2 months after the 5.3.1 release.

I suspect it was this patch about using A outside ::= context.

> So in the above example ${(P)var_name} returns a scalar and the (@)
> flag is also meaningless. In this next example --

I think @ has an actual effect:

> zsh-5.1.1
> abcdef=( a b ); var_name="abcdef"; array=( "${(PA@)var_name}" ); echo ${#array}
2
> ... array=( "${(P@)var_name}" ); echo ${#array}
2
> ... array=( "${(PA)var_name}" ); echo ${#array}
1
> ... array=( "${(P)var_name}" ); echo ${#array}
1

> resolve to nothing rather than to a quoted empty string, just as
> "${emptyarray[@]}" would do.

Yes it's a change for the better.

--
Sebastian Gniazdowski
psprint /at/ zdharma.org



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