Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Parameter name argument of sysread, read, print -v, what else?
- X-seq: zsh-workers 52483
- From: Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: Parameter name argument of sysread, read, print -v, what else?
- Date: Tue, 16 Jan 2024 20:44:32 -0800
- Archived-at: <https://zsh.org/workers/52483>
- List-id: <zsh-workers.zsh.org>
In his "slurp" example, Roman wrote:
sysread 'content[++i]'
Nifty, but raises an issue we've tackled elsewhere, e.g.
horse='content[$(eval $trojans)]'
sysread $horse
This is disallowed in named references by imposing noexec around the
subscript expansion. There's an uncommitted patch from Oliver
(workers/52293) using a similar technique for a similar concern about
[[ -v $var ]] (raised in users/29343).
In the nameref and [[ -v ... ]] cases the issue arose because of
calling getvalue() and is fixed by switching to fetchvalue(). For
sysread etc. the problem is from calling setsparam() which calls
assignsparam() ... which calls getvalue(). Similarly for setaparam()
+ assignaparam().
It would break swaths of stuff to to restrict subscript expansion in
every case of setting a parameter, so we can't attack this at the
lowest level without altering call signatures of at least some portion
of the function chain.
Is this just something we acknowledge and perhaps document? Thoughts?
Messages sorted by:
Reverse Date,
Date,
Thread,
Author