2
1

bash-4.2-025.patch 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 4.2
  4. Patch-ID: bash42-025
  5. Bug-Reported-by: Bill Gradwohl <bill@ycc.com>
  6. Bug-Reference-ID: <CAFyvKis-UfuOWr5THBRKh=vYHDoKEEgdW8hN1RviTuYQ00Lu5A@mail.gmail.com>
  7. Bug-Reference-URL: http://lists.gnu.org/archive/html/help-bash/2012-03/msg00078.html
  8. Bug-Description:
  9. When used in a shell function, `declare -g -a array=(compound assignment)'
  10. creates a local variable instead of a global one.
  11. Patch (apply with `patch -p0'):
  12. *** ../bash-4.2-patched/command.h 2010-08-02 19:36:51.000000000 -0400
  13. --- ./command.h 2012-04-01 12:38:35.000000000 -0400
  14. ***************
  15. *** 98,101 ****
  16. --- 98,102 ----
  17. #define W_ASSIGNASSOC 0x400000 /* word looks like associative array assignment */
  18. #define W_ARRAYIND 0x800000 /* word is an array index being expanded */
  19. + #define W_ASSNGLOBAL 0x1000000 /* word is a global assignment to declare (declare/typeset -g) */
  20. /* Possible values for subshell_environment */
  21. *** ../bash-4.2-patched/execute_cmd.c 2011-11-21 18:03:41.000000000 -0500
  22. --- ./execute_cmd.c 2012-04-01 12:42:03.000000000 -0400
  23. ***************
  24. *** 3581,3585 ****
  25. WORD_LIST *w;
  26. struct builtin *b;
  27. ! int assoc;
  28. if (words == 0)
  29. --- 3581,3585 ----
  30. WORD_LIST *w;
  31. struct builtin *b;
  32. ! int assoc, global;
  33. if (words == 0)
  34. ***************
  35. *** 3587,3591 ****
  36. b = 0;
  37. ! assoc = 0;
  38. for (w = words; w; w = w->next)
  39. --- 3587,3591 ----
  40. b = 0;
  41. ! assoc = global = 0;
  42. for (w = words; w; w = w->next)
  43. ***************
  44. *** 3604,3607 ****
  45. --- 3604,3609 ----
  46. if (assoc)
  47. w->word->flags |= W_ASSIGNASSOC;
  48. + if (global)
  49. + w->word->flags |= W_ASSNGLOBAL;
  50. #endif
  51. }
  52. ***************
  53. *** 3609,3613 ****
  54. /* Note that we saw an associative array option to a builtin that takes
  55. assignment statements. This is a bit of a kludge. */
  56. ! else if (w->word->word[0] == '-' && strchr (w->word->word, 'A'))
  57. {
  58. if (b == 0)
  59. --- 3611,3618 ----
  60. /* Note that we saw an associative array option to a builtin that takes
  61. assignment statements. This is a bit of a kludge. */
  62. ! else if (w->word->word[0] == '-' && (strchr (w->word->word+1, 'A') || strchr (w->word->word+1, 'g')))
  63. ! #else
  64. ! else if (w->word->word[0] == '-' && strchr (w->word->word+1, 'g'))
  65. ! #endif
  66. {
  67. if (b == 0)
  68. ***************
  69. *** 3619,3626 ****
  70. words->word->flags |= W_ASSNBLTIN;
  71. }
  72. ! if (words->word->flags & W_ASSNBLTIN)
  73. assoc = 1;
  74. }
  75. - #endif
  76. }
  77. --- 3624,3632 ----
  78. words->word->flags |= W_ASSNBLTIN;
  79. }
  80. ! if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'A'))
  81. assoc = 1;
  82. + if ((words->word->flags & W_ASSNBLTIN) && strchr (w->word->word+1, 'g'))
  83. + global = 1;
  84. }
  85. }
  86. *** ../bash-4.2-patched/subst.c 2012-03-11 17:35:13.000000000 -0400
  87. --- ./subst.c 2012-04-01 12:38:35.000000000 -0400
  88. ***************
  89. *** 367,370 ****
  90. --- 367,375 ----
  91. fprintf (stderr, "W_ASSNBLTIN%s", f ? "|" : "");
  92. }
  93. + if (f & W_ASSNGLOBAL)
  94. + {
  95. + f &= ~W_ASSNGLOBAL;
  96. + fprintf (stderr, "W_ASSNGLOBAL%s", f ? "|" : "");
  97. + }
  98. if (f & W_COMPASSIGN)
  99. {
  100. ***************
  101. *** 2804,2808 ****
  102. else if (assign_list)
  103. {
  104. ! if (word->flags & W_ASSIGNARG)
  105. aflags |= ASS_MKLOCAL;
  106. if (word->flags & W_ASSIGNASSOC)
  107. --- 2809,2813 ----
  108. else if (assign_list)
  109. {
  110. ! if ((word->flags & W_ASSIGNARG) && (word->flags & W_ASSNGLOBAL) == 0)
  111. aflags |= ASS_MKLOCAL;
  112. if (word->flags & W_ASSIGNASSOC)
  113. *** ../bash-4.2-patched/patchlevel.h Sat Jun 12 20:14:48 2010
  114. --- ./patchlevel.h Thu Feb 24 21:41:34 2011
  115. ***************
  116. *** 26,30 ****
  117. looks for to find the patch level (for the sccs version string). */
  118. ! #define PATCHLEVEL 24
  119. #endif /* _PATCHLEVEL_H_ */
  120. --- 26,30 ----
  121. looks for to find the patch level (for the sccs version string). */
  122. ! #define PATCHLEVEL 25
  123. #endif /* _PATCHLEVEL_H_ */