From dc4a13a372aecb1cd169bb2310dddaa142e129af Mon Sep 17 00:00:00 2001 From: David Schroeder Date: Thu, 31 Jan 2019 23:14:15 -0600 Subject: [PATCH] Update test.sh --- test.sh | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/test.sh b/test.sh index 91e7103..99c58f2 100755 --- a/test.sh +++ b/test.sh @@ -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 \ No newline at end of file