[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Help-bash] Passing multiple arrays to a function
From: |
Jerry |
Subject: |
[Help-bash] Passing multiple arrays to a function |
Date: |
Tue, 11 Dec 2018 09:00:24 -0500 |
bash version 4.4.23 on a FreeBSD 11.2 amd64 machine.
Don't laugh, I am still trying to learn how to use bash.
I am trying to pass arrays to a function. I can get it to work if I only pass
one function; however, I cannot figure out how to pass two or more arrays
simultaneously.
Below is a very simple example of what I am trying to do.
#!/usr/local/bin/bash
declare -A place=(
[first]="one"
[second]="two"
[third]="three")
declare -A teams=(
[ny]="mets"
[nj]="jersey"
[pa]="pittsburgh")
function standing () {
local -a arr_1=${1}
local -a arr_2=${2}
echo "address@hidden"
echo "address@hidden"
}
## Call the function
standing "address@hidden" "address@hidden"
Nothing gets displayed. I could use "address@hidden" instead of "${1}" or
"${2}", but
that just gobbles up all of the data into one array. Not what I want. I was
told to substitute "local -n" for "local -a", but that failed also.
Is this possible?
--
Jerry
- [Help-bash] Passing multiple arrays to a function,
Jerry <=