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

Re: ${(z)} parsing of multiple array assignments



On 2019-12-23 at 17:31 +0000, Daniel Shahaf wrote:
> In the following two cases, why are the assignments to $b
> parsed differently to the assignments to $a?
> 
>     % pz() { print -rl -- ${(qqqq)${(z)1}} }

Looks to be a bug, a lack of state reset.  In two places, perhaps: you
can see that one example resets when you alternate back away from having
empty assignment lists, where the b/c pairing here is reset by `d`, so
that the f/g pairing matches.  But I can't trigger a reset to the
initial parse state used for `a`; unless and until I introduce a
newline, where in the second example you can see the same parse used for
`e`:

    % echo $ZSH_VERSION
    5.7.1

    % x='a=(foo) b=() c=() d=(bar) e=(baz) f=() g=()'
    % print -rl -- "${(z)x}"
    a=(
    foo
    )
    b=
    ()
    c=(
    )
    d=(bar)
    e=(baz)
    f=
    ()
    g=(
    )

    ## differs in $'...' not '...' and \n between d and e:

    % x=$'a=(foo) b=() c=() d=(bar)\ne=(baz) f=() g=()'
    % print -rl -- "${(z)x}"
    a=(
    foo
    )
    b=
    ()
    c=(
    )
    d=(bar)
    ;
    e=(
    baz
    )
    f=
    ()
    g=(
    )



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