|
|
462fb2 |
BASH PATCH REPORT
|
|
|
462fb2 |
=================
|
|
|
462fb2 |
|
|
|
462fb2 |
Bash-Release: 4.2
|
|
|
462fb2 |
Patch-ID: bash42-025
|
|
|
462fb2 |
|
|
|
462fb2 |
Bug-Reported-by: Bill Gradwohl <bill@ycc.com>
|
|
|
462fb2 |
Bug-Reference-ID: <CAFyvKis-UfuOWr5THBRKh=vYHDoKEEgdW8hN1RviTuYQ00Lu5A@mail.gmail.com>
|
|
|
462fb2 |
Bug-Reference-URL: http://lists.gnu.org/archive/html/help-bash/2012-03/msg00078.html
|
|
|
462fb2 |
|
|
|
462fb2 |
Bug-Description:
|
|
|
462fb2 |
|
|
|
462fb2 |
When used in a shell function, `declare -g -a array=(compound assignment)'
|
|
|
462fb2 |
creates a local variable instead of a global one.
|
|
|
462fb2 |
|
|
|
462fb2 |
Patch (apply with `patch -p0'):
|
|
|
462fb2 |
|
|
|
462fb2 |
*** ../bash-4.2-patched/command.h 2010-08-02 19:36:51.000000000 -0400
|
|
|
462fb2 |
--- command.h 2012-04-01 12:38:35.000000000 -0400
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 98,101 ****
|
|
|
462fb2 |
--- 98,102 ----
|
|
|
462fb2 |
#define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
|
|
|
462fb2 |
#define W_ARRAYIND 0x800000 /* word is an array index being expanded */
|
|
|
462fb2 |
+ #define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */
|
|
|
462fb2 |
|
|
|
462fb2 |
/* Possible values for subshell_environment */
|
|
|
462fb2 |
*** ../bash-4.2-patched/execute_cmd.c 2011-11-21 18:03:41.000000000 -0500
|
|
|
462fb2 |
--- execute_cmd.c 2012-04-01 12:42:03.000000000 -0400
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 3581,3585 ****
|
|
|
462fb2 |
WORD_LIST *w;
|
|
|
462fb2 |
struct builtin *b;
|
|
|
462fb2 |
! int assoc;
|
|
|
462fb2 |
|
|
|
462fb2 |
if (words == 0)
|
|
|
462fb2 |
--- 3581,3585 ----
|
|
|
462fb2 |
WORD_LIST *w;
|
|
|
462fb2 |
struct builtin *b;
|
|
|
462fb2 |
! int assoc, global;
|
|
|
462fb2 |
|
|
|
462fb2 |
if (words == 0)
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 3587,3591 ****
|
|
|
462fb2 |
|
|
|
462fb2 |
b = 0;
|
|
|
462fb2 |
! assoc = 0;
|
|
|
462fb2 |
|
|
|
462fb2 |
for (w = words; w; w = w->next)
|
|
|
462fb2 |
--- 3587,3591 ----
|
|
|
462fb2 |
|
|
|
462fb2 |
b = 0;
|
|
|
462fb2 |
! assoc = global = 0;
|
|
|
462fb2 |
|
|
|
462fb2 |
for (w = words; w; w = w->next)
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 3604,3607 ****
|
|
|
462fb2 |
--- 3604,3609 ----
|
|
|
462fb2 |
if (assoc)
|
|
|
462fb2 |
w->word->flags |= W_ASSIGNASSOC;
|
|
|
462fb2 |
+ if (global)
|
|
|
462fb2 |
+ w->word->flags |= W_ASSNGLOBAL;
|
|
|
462fb2 |
#endif
|
|
|
462fb2 |
}
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 3609,3613 ****
|
|
|
462fb2 |
/* Note that we saw an associative array option to a builtin that takes
|
|
|
462fb2 |
assignment statements. This is a bit of a kludge. */
|
|
|
462fb2 |
! else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
|
|
|
462fb2 |
{
|
|
|
462fb2 |
if (b == 0)
|
|
|
462fb2 |
--- 3611,3618 ----
|
|
|
462fb2 |
/* Note that we saw an associative array option to a builtin that takes
|
|
|
462fb2 |
assignment statements. This is a bit of a kludge. */
|
|
|
462fb2 |
! else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
|
|
|
462fb2 |
! #else
|
|
|
462fb2 |
! else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
|
|
|
462fb2 |
! #endif
|
|
|
462fb2 |
{
|
|
|
462fb2 |
if (b == 0)
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 3619,3626 ****
|
|
|
462fb2 |
words->word->flags |= W_ASSNBLTIN;
|
|
|
462fb2 |
}
|
|
|
462fb2 |
! if (words->word->flags & W_ASSNBLTIN)
|
|
|
462fb2 |
assoc = 1;
|
|
|
462fb2 |
}
|
|
|
462fb2 |
- #endif
|
|
|
462fb2 |
}
|
|
|
462fb2 |
|
|
|
462fb2 |
--- 3624,3632 ----
|
|
|
462fb2 |
words->word->flags |= W_ASSNBLTIN;
|
|
|
462fb2 |
}
|
|
|
462fb2 |
! if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
|
|
|
462fb2 |
assoc = 1;
|
|
|
462fb2 |
+ if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
|
|
|
462fb2 |
+ global = 1;
|
|
|
462fb2 |
}
|
|
|
462fb2 |
}
|
|
|
462fb2 |
|
|
|
462fb2 |
*** ../bash-4.2-patched/subst.c 2012-03-11 17:35:13.000000000 -0400
|
|
|
462fb2 |
--- subst.c 2012-04-01 12:38:35.000000000 -0400
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 367,370 ****
|
|
|
462fb2 |
--- 367,375 ----
|
|
|
462fb2 |
fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
|
|
|
462fb2 |
}
|
|
|
462fb2 |
+ if (f & W_ASSNGLOBAL)
|
|
|
462fb2 |
+ {
|
|
|
462fb2 |
+ f &= ~W_ASSNGLOBAL;
|
|
|
462fb2 |
+ fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
|
|
|
462fb2 |
+ }
|
|
|
462fb2 |
if (f & W_COMPASSIGN)
|
|
|
462fb2 |
{
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 2804,2808 ****
|
|
|
462fb2 |
else if (assign_list)
|
|
|
462fb2 |
{
|
|
|
462fb2 |
! if (word->flags & W_ASSIGNARG)
|
|
|
462fb2 |
aflags |= ASS_MKLOCAL;
|
|
|
462fb2 |
if (word->flags & W_ASSIGNASSOC)
|
|
|
462fb2 |
--- 2809,2813 ----
|
|
|
462fb2 |
else if (assign_list)
|
|
|
462fb2 |
{
|
|
|
462fb2 |
! if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
|
|
|
462fb2 |
aflags |= ASS_MKLOCAL;
|
|
|
462fb2 |
if (word->flags & W_ASSIGNASSOC)
|
|
|
462fb2 |
|
|
|
462fb2 |
*** ../bash-4.2-patched/patchlevel.h Sat Jun 12 20:14:48 2010
|
|
|
462fb2 |
--- patchlevel.h Thu Feb 24 21:41:34 2011
|
|
|
462fb2 |
***************
|
|
|
462fb2 |
*** 26,30 ****
|
|
|
462fb2 |
looks for to find the patch level (for the sccs version string). */
|
|
|
462fb2 |
|
|
|
462fb2 |
! #define PATCHLEVEL 24
|
|
|
462fb2 |
|
|
|
462fb2 |
#endif /* _PATCHLEVEL_H_ */
|
|
|
462fb2 |
--- 26,30 ----
|
|
|
462fb2 |
looks for to find the patch level (for the sccs version string). */
|
|
|
462fb2 |
|
|
|
462fb2 |
! #define PATCHLEVEL 25
|
|
|
462fb2 |
|
|
|
462fb2 |
#endif /* _PATCHLEVEL_H_ */
|