bash -uc 'declare -a arr=( [idx]=val );echo ${arr[idx]}'

Bug #556101 reported by Imre Péntek
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
bash (Ubuntu)
Fix Released
Undecided
Unassigned

Bug Description

Binary package hint: bash

imi@most:~$ bash -uc 'declare -a arr=( [idx]=val );echo ${arr[idx]}'
bash: idx: unbound variable
imi@most:~$ bash -c 'declare -a arr=( [idx]=val );echo ${arr[idx]}'
val
imi@most:~$ bash -uc 'idx=dunno;declare -a arr=( [idx]=val );echo ${arr[idx]}'
bash: dunno: unbound variable
imi@most:~$ bash -uc 'idx="";declare -a arr=( [idx]=val );echo ${arr[idx]}'
val

According to bash man page associative arrays are supported, also, you can see the result when not using the -u flag. -u is to get error when trying to retrieve a value from a previously unset variable, so there's no point in getting error here, as idx isn't used as variable at all, it is used as an immediate string constant (e.g. as in `echo idx`) subscript.

ProblemType: Bug
Architecture: i386
Date: Tue Apr 6 01:25:09 2010
DistroRelease: Ubuntu 9.10
Package: bash 4.0-5ubuntu2
ProcEnviron:
 PATH=(custom, user)
 LANG=hu_HU.UTF-8
 SHELL=/bin/bash
ProcVersionSignature: Ubuntu 2.6.31-20.58-generic
SourcePackage: bash
Uname: Linux 2.6.31-20-generic i686

Related branches

Revision history for this message
Imre Péntek (pentek-imre) wrote :
Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package bash - 4.1-2ubuntu2

---------------
bash (4.1-2ubuntu2) lucid; urgency=low

  * Apply upstream patches 003, 004, 005.
    - Fix crash with command completion on a word with a quoted globbing
      character.
    - Fix executing a shell function in Posix mode without local
      variables, bash will not propagate a variable in a special builtin's
      temporary environment to have global scope.
    - Fix the `read' builtin times out after the timeout specified with -t
      is exceeded, it does not reset the flags that tell signal handlers to
      process signals immediately instead of deferring their handling.
  * Fix crash in declare builtin. LP: #556101.
  * README.Debian:
    - Remove references to bash-minimal.
    - Mention that the upstream changelog can be found in the bash-doc
      package.
 -- Matthias Klose <email address hidden> Sat, 10 Apr 2010 12:56:48 +0200

Changed in bash (Ubuntu):
status: New → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.