On Fri, Oct 22, 2010 at 12:04:14PM -0400, Chris F.A. Johnson wrote:
>Drop the qotes:
>
> declare -A foo=( [a]=5 )
That misses the point. The original poster was trying to initialize
an associative array using key/value pairs that were being fed through
a substitution. Like this, but using c
"Chris F.A. Johnson" writes:
> On Fri, 22 Oct 2010, Andreas Schwab wrote:
>
>> Axel writes:
>>
>>> After your answer, I checked and I think the error message is not
>>> related to the variable name collision :
>>>
>>> [a...@axel-asus plugins]$ unset foo
>>> [a...@axel-asus plugins]$ func()
On Fri, 22 Oct 2010, Andreas Schwab wrote:
Axel writes:
After your answer, I checked and I think the error message is not
related to the variable name collision :
[a...@axel-asus plugins]$ unset foo
[a...@axel-asus plugins]$ func()
{
echo "[a]=5 [b]=10"
}
[a...@axel-asus plugins]$ declare
Axel writes:
> After your answer, I checked and I think the error message is not
> related to the variable name collision :
>
> [a...@axel-asus plugins]$ unset foo
> [a...@axel-asus plugins]$ func()
>> {
>> echo "[a]=5 [b]=10"
>> }
> [a...@axel-asus plugins]$ declare -A foo=( $(func) )
$ declare
Le 22/10/2010 16:21, Greg Wooledge a écrit :
On Fri, Oct 22, 2010 at 02:59:37PM +0200, Axel wrote:
Anyway, since this syntax works for assigning indexed arrays (even if
it's a "hack"), should it works for associative array assignment ?
Maintainers will decide I assume.
But it doesn't. You used
On Fri, Oct 22, 2010 at 02:59:37PM +0200, Axel wrote:
> Anyway, since this syntax works for assigning indexed arrays (even if
> it's a "hack"), should it works for associative array assignment ?
> Maintainers will decide I assume.
But it doesn't. You used a totally different syntax for your ind
Le 22/10/2010 14:56, Chet Ramey a écrit :
And you're trying to redeclare it as an associative array here. The
variable already exists; you can't convert it between array types;
and bash tells you this. If you want an associative array, unset the
variable before you declare it.
After your ans
Le 22/10/2010 14:42, Greg Wooledge a écrit :
Unreliable at best. How do you handle elements that have whitespace
in them, for example? You have to know your data set, choose a delimiter
that can't be in that set, and then write code to parse the output stream
into elements.
At this moment, I
> An easy example is better than an explanation:
>
> # Woks well
> indexarray()
> {
> echo "5 6 7"
> }
> declare -a t1=( $(indexarray) )
> echo ${t1[1]} ${t1[0]}
So you now have an indexed array named `t1'.
> # Does not work
> assocarray()
> {
> echo "[a]=5 [b]=6"
> }
> declare -A t1=(
On Fri, Oct 22, 2010 at 10:26:27AM +0200, Axel wrote:
> I try to assign an array from the output of a function.
Unreliable at best. How do you handle elements that have whitespace
in them, for example? You have to know your data set, choose a delimiter
that can't be in that set, and then write c
10 matches
Mail list logo