zsh-users
 help / color / mirror / code / Atom feed
* easy calling of associative array?
@ 2015-11-01 23:12 Ray Andrews
  2015-11-01 23:55 ` ZyX
  0 siblings, 1 reply; 20+ messages in thread
From: Ray Andrews @ 2015-11-01 23:12 UTC (permalink / raw)
  To: Zsh Users


test ()
{
     eval "baz=\$${1}[key1]"
     echo $baz
eval "foo=\$${1}[key2]"
     echo $foo
...
}

If I want to pass the name of an associative array to a function via 
"$1" and then work with it's keys, the above succeeds but it's sure 
laborious. Is there some way to do the eval just once?  So that I can 
end up doing:

if [ "xyz[key1]" = '1' ]; then ...

... as I experiment, there seems to be no way of replacing 'xyz' with 
any expression that will do the job without needing eval's help every 
time, but I'll bet there's a way.


^ permalink raw reply	[flat|nested] 20+ messages in thread

end of thread, other threads:[~2015-11-04 18:31 UTC | newest]

Thread overview: 20+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-11-01 23:12 easy calling of associative array? Ray Andrews
2015-11-01 23:55 ` ZyX
2015-11-02  0:49   ` Ray Andrews
2015-11-02  3:08     ` Bart Schaefer
2015-11-02  3:33       ` Ray Andrews
2015-11-02  6:51         ` Bart Schaefer
2015-11-02 15:43           ` Ray Andrews
2015-11-02 16:28             ` Bart Schaefer
2015-11-02 18:32               ` Ray Andrews
2015-11-02 19:37                 ` ZyX
2015-11-02 22:10                   ` Bart Schaefer
2015-11-02 22:50                     ` Ray Andrews
2015-11-02 21:05                 ` Bart Schaefer
2015-11-02 23:01                   ` Ray Andrews
2015-11-03 15:57                     ` Bart Schaefer
2015-11-04 14:48                       ` Ray Andrews
2015-11-04 16:39                         ` Bart Schaefer
2015-11-04 18:31                           ` Ray Andrews
2015-11-02 19:33             ` ZyX
2015-11-02 23:04               ` Ray Andrews

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).