Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
namerefs to var[idx]
- X-seq: zsh-workers 52712
- From: Stephane Chazelas <stephane@xxxxxxxxxxxx>
- To: Zsh hackers list <zsh-workers@xxxxxxx>
- Subject: namerefs to var[idx]
- Date: Fri, 8 Mar 2024 13:23:07 +0000
- Archived-at: <https://zsh.org/workers/52712>
- List-id: <zsh-workers.zsh.org>
- Mail-followup-to: Zsh hackers list <zsh-workers@xxxxxxx>
$ f() { typeset -nu v=$1; echo ${v[1]}; }
$ a=abcd
$ f 'a[2,3]'
b
OK but:
$ f() { typeset -nu v=$1; echo $v[1]; }
$ f 'a[2,3]'
f: no matches found: bc[1]
It's amazing that these actually work:
$ f() { typeset -nu v=$1; v[1]=foo; }
$ f a
$ echo $a
foo2345
$ f 'a[6]'
$ echo $a
foo23foo5
This one not really:
$ a=12345
$ f 'a[2,3]'
$ echo $a
1foo45
In that one could expect the first character of the "23"
substring to be changed to "foo", but I can see that's asking
quite a lot.
--
Stephane
Messages sorted by:
Reverse Date,
Date,
Thread,
Author