rcolebaugh / rpms / bash

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