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 Wed, Jun 14, 2017 at 10:09 AM, Sebastian Gniazdowski
<psprint@xxxxxxxxxxx> 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.

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

> % zsh-5.3.1-dev-0
> % var_name="abcdef"; array=( "${(PA@)var_name}" ); echo ${#array}
> 0

-- the (A) flag does apply , so ${(PA)var_name} is an empty array
rather than an unset scalar, and (@) causes the double-quotes to
resolve to nothing rather than to a quoted empty string, just as
"${emptyarray[@]}" would do.



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