Hello

I try to assign an array from the output of a function. As this works for indexed arrays, it does not for associative arrays. I m using "GNU bash, version 4.1.7(1)-release (x86_64-redhat-linux-gnu)" on a Fedora 13 system.
An easy example is better than an explanation:

# Woks well
indexarray()
{
    echo "5 6 7"
}
declare -a t1=( $(indexarray) )
echo ${t1[1]} ${t1[0]}

# Does not work
assocarray()
{
    echo "[a]=5 [b]=6"
}
declare -A t1=( $(assocarray) ) # The error occurs here

The given error message is "cannot convert indexed to associative array". Is this behaviour intended ? Is there a known workaround for this ?

I didnt find any "users" maling-list and I m not really sure this one fit to my message, since this may (or may not) be a bug report.

Thanks for your answers, regards.


Reply via email to