[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/1.4.2.3i |
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
#!/bin/ksh
foo() {
nameref array="$1"
array[42]=forty-two
}
foo bar
for i in "address@hidden"; do
echo "bar[$i]=${bar[i]}"
done
arc3:~$ ./foo
bar[42]=forty-two
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.
- [Help-bash] indirection for arrays, Bill Gradwohl, 2012/05/05
- Re: [Help-bash] indirection for arrays, John Kearney, 2012/05/05
- Re: [Help-bash] indirection for arrays, Dan Douglas, 2012/05/05
- Re: [Help-bash] indirection for arrays,
Greg Wooledge <=
- Re: [Help-bash] indirection for arrays, Dan Douglas, 2012/05/09
- Re: [Help-bash] indirection for arrays, Chet Ramey, 2012/05/09
- Re: [Help-bash] indirection for arrays, Dan Douglas, 2012/05/09