Update test.sh
This commit is contained in:
15
test.sh
15
test.sh
@@ -20,15 +20,20 @@ fi
|
|||||||
|
|
||||||
function myfunc()
|
function myfunc()
|
||||||
{
|
{
|
||||||
local __resultvar=$1
|
local -n myresult="$1" || return 1
|
||||||
local declare -A myresult
|
|
||||||
myresult[0]="a"
|
myresult[0]="a"
|
||||||
myresult[1]="b"
|
myresult[1]="b"
|
||||||
myresult[2]="c"
|
myresult[2]="c"
|
||||||
myresult[3]="d"
|
myresult[3]="d"
|
||||||
myresult[4]="e"
|
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
|
|
||||||
Reference in New Issue
Block a user