Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
no-fork expansion with array var
- X-seq: zsh-workers 52173
- From: Mikael Magnusson <mikachu@xxxxxxxxx>
- To: zsh-workers@xxxxxxx
- Subject: no-fork expansion with array var
- Date: Fri, 22 Sep 2023 23:00:19 +0200
- Archived-at: <https://zsh.org/workers/52173>
- List-id: <zsh-workers.zsh.org>
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