rcolebaugh / rpms / bash

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