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

Parameter name argument of sysread, read, print -v, what else?



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