[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: |
Thu, 26 Feb 2009 14:51:42 -0500 |
User-agent: |
Thunderbird 2.0.0.19 (Macintosh/20081209) |
Pierre Gaston wrote:
> sorry if this mail arrives twice, but the first mail didn't seem to
> made it through.
>
> Configuration Information [Automatically generated, do not change]:
> Machine: i386
> OS: openbsd4.4
> Compiler: gcc
> Compilation CFLAGS: -DPROGRAM='bash' -DCONF_HOSTTYPE='i386'
> -DCONF_OSTYPE='openbsd4.4' -DCONF_MACHTYPE='i386-unknown-openbsd4.4'
> -DCONF_VENDOR='unknown' -DLOCALEDIR='/usr/local/share/locale'
> -DPACKAGE='bash' -DSHELL -DHAVE_CONFIG_H -I. -I. -I./include -I./lib
> -I/usr/local/include -g -O2
> uname output: OpenBSD obsd1 4.4 GENERIC#1021 i386
> 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
I've attached a patch that fixes both problems. It supersedes what I
previously posted, and should be applied to a vanilla bash-4.0 copy of
builtins/declare.def. It should be the same as the official patch, when
I release the first batch.
Chet
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
Chet Ramey, ITS, CWRU chet@case.edu http://cnswww.cns.cwru.edu/~chet/
*** ../bash-4.0/builtins/declare.def 2009-01-04 14:32:22.000000000 -0500
--- builtins/declare.def 2009-02-26 11:40:16.000000000 -0500
***************
*** 296,299 ****
--- 296,306 ----
if (t = strchr (name, '[')) /* ] */
{
+ /* If offset != 0 we have already validated any array reference */
+ if (offset == 0 && valid_array_reference (name) == 0)
+ {
+ sh_invalidid (name);
+ assign_error++;
+ NEXT_VARIABLE ();
+ }
subscript_start = t;
*t = '\0';
***************
*** 485,489 ****
/* declare -a name[[n]] or declare name[n] makes name an indexed
array variable. */
! else if ((making_array_special || (flags_on & att_array)) && array_p
(var) == 0)
var = convert_var_to_array (var);
#endif /* ARRAY_VARS */
--- 492,496 ----
/* declare -a name[[n]] or declare name[n] makes name an indexed
array variable. */
! else if ((making_array_special || (flags_on & att_array)) && array_p
(var) == 0 && assoc_p (var) == 0)
var = convert_var_to_array (var);
#endif /* ARRAY_VARS */