[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Single quote character not handled well in associative array index
From: |
Jarno Suni |
Subject: |
Single quote character not handled well in associative array index |
Date: |
Tue, 30 Aug 2016 00:57:12 +0300 |
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='bash'
-DSHELL -DHAVE_CONFIG_H -I. -I../. -I.././include -I.././lib
-Wdate-time -D_FORTIFY_SOURCE=2 -g -O2 -fstack-protector-strong
-Wformat -Werror=format-security -Wall
uname output: Linux jarno-hp8510w 4.4.0-31-generic #50-Ubuntu SMP Wed
Jul 13 00:07:12 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 4.3
Patch Level: 46
Release Status: release
Description:
Using associative array variable that has a single quote in index does
not work withing (( )) without a trick.
Repeat-By:
declare -A a
b="80's"
((++a[$b]))
((++a["$b"]))
[[ $((++a[$b])) ]] || true
[[ $((++a["$b"])) ]] || true # this finally works and makes the variable =1
echo ${a["$b"]}
echo ${a[$b]}
- Single quote character not handled well in associative array index,
Jarno Suni <=