[Top][All Lists]

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

Re: [Help-bash] indirection for arrays

From: Greg Wooledge
Subject: Re: [Help-bash] indirection for arrays
Date: Mon, 7 May 2012 08:22:51 -0400
User-agent: Mutt/

On Sat, May 05, 2012 at 02:16:36PM -0600, Bill Gradwohl wrote:
> Via a web site reference, Dan Douglas (Thank You) provided something akin
> to this:
> func() {
>     local -a 'keys=("${!'"$1"'address@hidden")'

It burns!!

> declare -a myArray=(1 2 3)
> func 'myArray'

For the love of god, if you want to pass arrays to a function by name,
use ksh93, not bash.

arc3:~$ cat foo
foo() {
  nameref array="$1"
foo bar
for i in "address@hidden"; do
  echo "bar[$i]=${bar[i]}"
arc3:~$ ./foo

UNTIL SUCH TIME as bash has a feature like this, you cannot do this in
bash.  Throwing dozens of random punctuation characters at the screen
until the code appears to do what you think it should do is not sane.

reply via email to

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