bug-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

associative array assignment from the output of a function


From: Axel
Subject: associative array assignment from the output of a function
Date: Fri, 22 Oct 2010 10:26:27 +0200
User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; fr; rv:1.9.2.11) Gecko/20101013 Lightning/1.0b2 Thunderbird/3.1.5

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

[Prev in Thread] Current Thread [Next in Thread]