[Top][All Lists]

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

Re: bash stuck in a loop defining arrays

From: Chet Ramey
Subject: Re: bash stuck in a loop defining arrays
Date: Wed, 25 Feb 2009 09:46:09 -0500

> Machine Type: i386-unknown-openbsd4.4
> Bash Version: 4.0
> Patch Level: 0
> Description:
>         playing with the associative arrays, bash ends up in what appears
> to be a busy loop that I cannot interupt with C-c
> Repeat-By:
> bash-4.0$ declare -A array
> bash-4.0$ declare array["foo[bar"]=bleh
> bash-4.0$ array["foo"]=bleh

You tricked the shell.  Bash isn't smart enough to realize you're assigning
to an associative array, and performs quote removal on the assignment
before running `declare'.

What ends up happening is that the shell tries to create a variable named
'array[foo[bar]=bleh', since the dequoted word is no longer a valid
assignment statement.  This leads to all sorts of weird behavior, since
some of the code's assumptions are violated.

The attached patch should catch the attempts to create invalid variables
and flag them as errors.


Attachment: declare-identifier
Description: Text document

``The lyf so short, the craft so long to lerne.'' - Chaucer

Chet Ramey, ITS, CWRU    address@hidden    http://tiswww.tis.case.edu/~chet/

reply via email to

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