Update test.sh

This commit is contained in:
2019-01-31 23:14:15 -06:00
parent 8d676f0104
commit dc4a13a372

15
test.sh
View File

@@ -20,15 +20,20 @@ fi
function myfunc()
{
local __resultvar=$1
local declare -A myresult
local -n myresult="$1" || return 1
myresult[0]="a"
myresult[1]="b"
myresult[2]="c"
myresult[3]="d"
myresult[4]="e"
eval $__resultvar="'$myresult'"
}
generatearray() {
# $1 is array name in which array is generated
local -n array="$1" || return 1
array=( foo doo coo )
}
# call function that constructs the array with the array name
myfunc targetvalue
# display it
declare -p targetvalue
myfunc result
echo $result