bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: currently doable? Indirect notation used w/a hash


From: Chris F.A. Johnson
Subject: Re: currently doable? Indirect notation used w/a hash
Date: Mon, 10 Jun 2013 09:10:17 -0400 (EDT)
User-agent: Alpine 2.02 (DEB 1266 2009-07-14)

On Mon, 10 Jun 2013, Greg Wooledge wrote:

On Sun, Jun 09, 2013 at 02:02:02PM -0700, Linda Walsh wrote:
I was wondering if I was missing some syntax somewhere...
but I wanted to be able to pass the name of a hash in
and store stuff in it and later retrieve it... but it
looks like it's only possible with an eval or such?

Passing arrays "by reference" (by name) to a function will be possible
in bash 4.3.  It is not possible in current versions of bash, without
using eval trickery, as you have already noted.  And doing it with
eval is so difficult that it's easier to switch languages entirely.

   It is not the least bit difficult with eval:

eval "array=( \"\${$1[@]}\" )"

--
   Chris F.A. Johnson, <http://cfajohnson.com/>
   Author:
   Pro Bash Programming: Scripting the GNU/Linux Shell (2009, Apress)
   Shell Scripting Recipes: A Problem-Solution Approach (2005, Apress)



reply via email to

[Prev in Thread] Current Thread [Next in Thread]