components/bash/patches/bash42-025.patch
changeset 1082 6d49548fa9da
equal deleted inserted replaced
1081:3d086c82286d 1082:6d49548fa9da
       
     1 			     BASH PATCH REPORT
       
     2 			     =================
       
     3 
       
     4 Bash-Release:	4.2
       
     5 Patch-ID:	bash42-025
       
     6 
       
     7 Bug-Reported-by:	Bill Gradwohl <[email protected]>
       
     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
       
    10 
       
    11 Bug-Description:
       
    12 
       
    13 When used in a shell function, `declare -g -a array=(compound assignment)'
       
    14 creates a local variable instead of a global one.
       
    15 
       
    16 Patch (apply with `patch -p0'):
       
    17 
       
    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
       
    20 ***************
       
    21 *** 98,101 ****
       
    22 --- 98,102 ----
       
    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) */
       
    26   
       
    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
       
    30 ***************
       
    31 *** 3581,3585 ****
       
    32     WORD_LIST *w;
       
    33     struct builtin *b;
       
    34 !   int assoc;
       
    35   
       
    36     if (words == 0)
       
    37 --- 3581,3585 ----
       
    38     WORD_LIST *w;
       
    39     struct builtin *b;
       
    40 !   int assoc, global;
       
    41   
       
    42     if (words == 0)
       
    43 ***************
       
    44 *** 3587,3591 ****
       
    45   
       
    46     b = 0;
       
    47 !   assoc = 0;
       
    48   
       
    49     for (w = words; w; w = w->next)
       
    50 --- 3587,3591 ----
       
    51   
       
    52     b = 0;
       
    53 !   assoc = global = 0;
       
    54   
       
    55     for (w = words; w; w = w->next)
       
    56 ***************
       
    57 *** 3604,3607 ****
       
    58 --- 3604,3609 ----
       
    59   	if (assoc)
       
    60   	  w->word->flags |= W_ASSIGNASSOC;
       
    61 + 	if (global)
       
    62 + 	  w->word->flags |= W_ASSNGLOBAL;
       
    63   #endif
       
    64         }
       
    65 ***************
       
    66 *** 3609,3613 ****
       
    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'))
       
    70         {
       
    71   	if (b == 0)
       
    72 --- 3611,3618 ----
       
    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')))
       
    76 ! #else
       
    77 !     else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
       
    78 ! #endif
       
    79         {
       
    80   	if (b == 0)
       
    81 ***************
       
    82 *** 3619,3626 ****
       
    83   	      words->word->flags |= W_ASSNBLTIN;
       
    84   	  }
       
    85 ! 	if (words->word->flags & W_ASSNBLTIN)
       
    86   	  assoc = 1;
       
    87         }
       
    88 - #endif
       
    89   }
       
    90   
       
    91 --- 3624,3632 ----
       
    92   	      words->word->flags |= W_ASSNBLTIN;
       
    93   	  }
       
    94 ! 	if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
       
    95   	  assoc = 1;
       
    96 + 	if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
       
    97 + 	  global = 1;
       
    98         }
       
    99   }
       
   100   
       
   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
       
   103 ***************
       
   104 *** 367,370 ****
       
   105 --- 367,375 ----
       
   106         fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
       
   107       }
       
   108 +   if (f & W_ASSNGLOBAL)
       
   109 +     {
       
   110 +       f &= ~W_ASSNGLOBAL;
       
   111 +       fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
       
   112 +     }
       
   113     if (f & W_COMPASSIGN)
       
   114       {
       
   115 ***************
       
   116 *** 2804,2808 ****
       
   117     else if (assign_list)
       
   118       {
       
   119 !       if (word->flags & W_ASSIGNARG)
       
   120   	aflags |= ASS_MKLOCAL;
       
   121         if (word->flags & W_ASSIGNASSOC)
       
   122 --- 2809,2813 ----
       
   123     else if (assign_list)
       
   124       {
       
   125 !       if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
       
   126   	aflags |= ASS_MKLOCAL;
       
   127         if (word->flags & W_ASSIGNASSOC)
       
   128 
       
   129 *** ../bash-4.2-patched/patchlevel.h	Sat Jun 12 20:14:48 2010
       
   130 --- patchlevel.h	Thu Feb 24 21:41:34 2011
       
   131 ***************
       
   132 *** 26,30 ****
       
   133      looks for to find the patch level (for the sccs version string). */
       
   134   
       
   135 ! #define PATCHLEVEL 24
       
   136   
       
   137   #endif /* _PATCHLEVEL_H_ */
       
   138 --- 26,30 ----
       
   139      looks for to find the patch level (for the sccs version string). */
       
   140   
       
   141 ! #define PATCHLEVEL 25
       
   142   
       
   143   #endif /* _PATCHLEVEL_H_ */