Re: Space as a key in an associative array - different behaviours

2018-01-26 Thread Chet Ramey
On 1/25/18 3:45 PM, Chet Ramey wrote: > These two commands are basically equivalent. By the time the expression > evaluation is performed, the expression has undergone word expansion, > and the expression is "A[ ]++" or "A[ ]=1", respectively. Bash doesn't > allow blank array subscripts, and when

Re: Space as a key in an associative array - different behaviours

2018-01-25 Thread Chet Ramey
On 1/25/18 8:48 AM, Tomasz Warniełło wrote: > Bash Version: 4.4 > Patch Level: 12 > Release Status: release > > Description: > When trying to assign to a space key of an associative array, > the result differs with regards to the way the operation is performed. > 1. ((A[$a]++)) > 2. let "A[' ']++

Re: Space as a key in an associative array - different behaviours

2018-01-25 Thread Tomasz Warniełło
(Sorry for my previous mail. I sent it too early by mistake. Please delete it. Here's the full version.) Some single quotes... `let` is more consistent with them: $ unset A; a=" ";declare -A A; let "A['$a']++"; declare -p A declare -A A=([" "]="1" ) $ unset A; a=" ";declare -A A; let "A[''$a]++"

Re: Space as a key in an associative array - different behaviours

2018-01-25 Thread Tomasz Warniełło
Some single quotes... 1. `let` is more consistent with them: $ unset A; a=" ";declare -A A; let "A['$a']++"; declare -p A declare -A A=([" "]="1" ) $ unset A; a=" ";declare -A A; let "A[''$a]++"; declare -p A declare -A A=([" "]="1" ) $ unset A; a=" ";declare -A A; let "A[$a'']++"; declare -p A d

Re: Space as a key in an associative array - different behaviours

2018-01-25 Thread Greg Wooledge
On Thu, Jan 25, 2018 at 02:48:47PM +0100, Tomasz Warniełło wrote: > Repeat-By: > 1. > $ unset A; a=" ";declare -A A; ((A[$a]++)); declare -p A > declare -A A > > 2. > $ unset A; a=" ";declare -A A; let "A[$a]=1"; declare -p A > declare -A A > > 3. > $ unset A; a=" ";declare -A A; A[$a]=1; declare

Space as a key in an associative array - different behaviours

2018-01-25 Thread Tomasz Warniełło
Configuration Information [Automatically generated, do not change]: Machine: x86_64 OS: linux-gnu Compiler: gcc Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='x86_64' -DCONF_OSTYPE='linux-gnu' -DCONF_MACHTYPE='x86_64-pc-linux-gnu' -DCONF_VENDOR='pc' -DLOCALEDIR='/usr/share/locale' -DPACKAGE