7 Bug-Reported-by: Bill Gradwohl <bill@ycc.com>
8 Bug-Reference-ID: <CAFyvKis-UfuOWr5THBRKh=vYHDoKEEgdW8hN1RviTuYQ00Lu5A@mail.gmail.com>
9 Bug-Reference-URL: http://lists.gnu.org/archive/html/help-bash/2012-03/msg00078.html
13 When used in a shell function, `declare -g -a array=(compound assignment)'
14 creates a local variable instead of a global one.
16 Patch (apply with `patch -p0'):
18 *** ../bash-4.2-patched/command.h 2010-08-02 19:36:51.000000000 -0400
19 --- command.h 2012-04-01 12:38:35.000000000 -0400
23 #define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
24 #define W_ARRAYIND 0x800000 /* word is an array index being expanded */
25 + #define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */
27 /* Possible values for subshell_environment */
28 *** ../bash-4.2-patched/execute_cmd.c 2011-11-21 18:03:41.000000000 -0500
29 --- execute_cmd.c 2012-04-01 12:42:03.000000000 -0400
49 for (w = words; w; w = w->next)
55 for (w = words; w; w = w->next)
60 w->word->flags |= W_ASSIGNASSOC;
62 + w->word->flags |= W_ASSNGLOBAL;
67 /* Note that we saw an associative array option to a builtin that takes
68 assignment statements. This is a bit of a kludge. */
69 ! else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
73 /* Note that we saw an associative array option to a builtin that takes
74 assignment statements. This is a bit of a kludge. */
75 ! else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
77 ! else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
83 words->word->flags |= W_ASSNBLTIN;
85 ! if (words->word->flags & W_ASSNBLTIN)
92 words->word->flags |= W_ASSNBLTIN;
94 ! if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
96 + if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
101 *** ../bash-4.2-patched/subst.c 2012-03-11 17:35:13.000000000 -0400
102 --- subst.c 2012-04-01 12:38:35.000000000 -0400
106 fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
108 + if (f & W_ASSNGLOBAL)
110 + f &= ~W_ASSNGLOBAL;
111 + fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
113 if (f & W_COMPASSIGN)
117 else if (assign_list)
119 ! if (word->flags & W_ASSIGNARG)
120 aflags |= ASS_MKLOCAL;
121 if (word->flags & W_ASSIGNASSOC)
123 else if (assign_list)
125 ! if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
126 aflags |= ASS_MKLOCAL;
127 if (word->flags & W_ASSIGNASSOC)
129 *** ../bash-4.2-patched/patchlevel.h Sat Jun 12 20:14:48 2010
130 --- patchlevel.h Thu Feb 24 21:41:34 2011
133 looks for to find the patch level (for the sccs version string). */
135 ! #define PATCHLEVEL 24
137 #endif /* _PATCHLEVEL_H_ */
139 looks for to find the patch level (for the sccs version string). */
141 ! #define PATCHLEVEL 25
143 #endif /* _PATCHLEVEL_H_ */