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

no-fork expansion with array var



The documentation says:
  If param names an array, array expansion rules apply.

But what it means is if you do an array assignment to var inside the
code block, array expansion rules apply:
% typeset -a foo; print -rl - ${${|foo| foo=hi}[1]}
h
% typeset +a foo; print -rl - ${${|foo| foo=(hi)}[1]}
hi

I know that REPLY is special cased, but I also found this confusing:
% print -rl - ${|REPLY| REPLY=(hi there)} ${|REPLYY| REPLYY=(hi there)}
hi there
hi
there

restoring REPLY around the expansion shouldn't affect whether it was
returned as an array from inside the block, should it? Or we should at
least document that the special name REPLY is always expanded as a
scalar, whether it's named or used as the default name via
${|REPLY=(foo bar)}.

-- 
Mikael Magnusson




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