bug-bash
[Top][All Lists]
Advanced

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

associative array assignment is more constrained when using () construct


From: Michal Soltys
Subject: associative array assignment is more constrained when using () construct, than when using direct [] assignment
Date: Mon, 14 Nov 2011 17:15:14 +0100
User-agent: Mozilla/5.0 (Windows NT 5.2; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0

For example:

declare -A foo
foo['ab]']=bar

will work perfectly fine, but:

declare -A foo
foo=( ['ab]']=bar )

will end with following error:

-bash: [ab]]=bar: bad array subscript

Same with double quotes, or backslash quoting. It's still possible to 
quote that right bracket with backslash inside single quotes, but while
it will do the assignment without errors, the key will be different.

There's no mention in documentation about () specific constraints, 
so it looks like a small bug.

Tested with:

BASH_VERSINFO=([0]="4" [1]="2" [2]="10" [3]="2" [4]="release" 
[5]="i686-pc-linux-gnu")
BASH_VERSION='4.2.10(2)-release'


p.s.
keep me in CC, as I'm not subscribed



reply via email to

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