svashisht / rpms / bash

Forked from rpms/bash 4 years ago
Clone

Blame SOURCES/bash42-025

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