Public bug reported:

Say you have script named test.sh in current directory

#!/bin/bash
declare -A a
b="80's"
((++a[$b]))
((++a["$b"]))
[[ $((++a[$b])) ]] || true
[[ $((++a["$b"])) ]] || true
echo ${a["$b"]}
echo ${a[$b]}

It outputs

./test.sh: line 4: ((: ++a[80's]: bad array subscript (error token is "a[80's]")
./test.sh: line 5: ((: ++a[80's]: bad array subscript (error token is "a[80's]")
./test.sh: line 6: ++a[80's]: bad array subscript (error token is "a[80's]")
1
1

Expected output is

4
4

like it is when b is "80s". Note that only the incremention on line 7 of the 
script works.
This bug also happens by bash 4.3-7ubuntu1.5 (Trusty)

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: bash 4.3-14ubuntu1.1
ProcVersionSignature: Ubuntu 4.4.0-31.50-generic 4.4.13
Uname: Linux 4.4.0-31-generic x86_64
NonfreeKernelModules: nvidia_uvm nvidia
ApportVersion: 2.20.1-0ubuntu2.1
Architecture: amd64
CurrentDesktop: XFCE
Date: Tue Aug 30 00:24:58 2016
EcryptfsInUse: Yes
InstallationDate: Installed on 2015-11-21 (282 days ago)
InstallationMedia: Xubuntu 15.10 "Wily Werewolf" - Release amd64 (20151021)
SourcePackage: bash
UpgradeStatus: Upgraded to xenial on 2016-06-24 (66 days ago)

** Affects: bash (Ubuntu)
     Importance: Undecided
         Status: New


** Tags: amd64 apport-bug xenial

-- 
You received this bug notification because you are a member of Ubuntu
Bugs, which is subscribed to Ubuntu.
https://bugs.launchpad.net/bugs/1618224

Title:
  Single quote character not handled well in associative array index

To manage notifications about this bug go to:
https://bugs.launchpad.net/ubuntu/+source/bash/+bug/1618224/+subscriptions

-- 
ubuntu-bugs mailing list
[email protected]
https://lists.ubuntu.com/mailman/listinfo/ubuntu-bugs

Reply via email to