bash52-006.patch 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294
  1. BASH PATCH REPORT
  2. =================
  3. Bash-Release: 5.2
  4. Patch-ID: bash52-006
  5. Bug-Reported-by: feng xiangjun <fengxj325@gmail.com>
  6. Bug-Reference-ID: <CAHH2t87LrCmO=gdyWOmGn5WJt7EucL+iOXzrry34OETe50S6uA@mail.gmail.com>
  7. Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00089.html
  8. Bug-Description:
  9. In interactive shells, interrupting the shell while entering a command
  10. substitution can inhibit alias expansion.
  11. Patch (apply with `patch -p0'):
  12. *** ../bash-5.2-patched/parse.y 2022-10-08 13:10:06.000000000 -0400
  13. --- parse.y 2022-10-14 10:03:19.000000000 -0400
  14. ***************
  15. *** 3307,3310 ****
  16. --- 3307,3312 ----
  17. extended_glob = global_extglob;
  18. #endif
  19. + if (parser_state & (PST_CMDSUBST|PST_STRING))
  20. + expand_aliases = expaliases_flag;
  21. parser_state = 0;
  22. ***************
  23. *** 4389,4392 ****
  24. --- 4391,4395 ----
  25. parser_state |= PST_NOERROR;
  26. + parser_state |= PST_STRING;
  27. expand_aliases = 0;
  28. ***************
  29. *** 6402,6406 ****
  30. parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
  31. /* State flags we want to set for this run through the tokenizer. */
  32. ! parser_state |= PST_COMPASSIGN|PST_REPARSE;
  33. }
  34. --- 6405,6409 ----
  35. parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
  36. /* State flags we want to set for this run through the tokenizer. */
  37. ! parser_state |= PST_COMPASSIGN|PST_REPARSE|PST_STRING;
  38. }
  39. *** ../bash-20221007/parser.h 2022-08-30 11:39:56.000000000 -0400
  40. --- parser.h 2022-10-14 09:56:18.000000000 -0400
  41. ***************
  42. *** 51,54 ****
  43. --- 51,55 ----
  44. #define PST_NOEXPAND 0x400000 /* don't expand anything in read_token_word; for command substitution */
  45. #define PST_NOERROR 0x800000 /* don't print error messages in yyerror */
  46. + #define PST_STRING 0x1000000 /* parsing a string to a command or word list */
  47. /* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */
  48. *** ../bash-20221007/builtins/shopt.def 2022-10-07 10:25:55.000000000 -0400
  49. --- builtins/shopt.def 2022-10-14 09:30:11.000000000 -0400
  50. ***************
  51. *** 150,153 ****
  52. --- 150,156 ----
  53. #endif
  54. + int expaliases_flag = 0;
  55. + static int shopt_set_expaliases PARAMS((char *, int));
  56. +
  57. static int shopt_set_debug_mode PARAMS((char *, int));
  58. ***************
  59. *** 199,203 ****
  60. { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
  61. { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
  62. ! { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
  63. #if defined (DEBUGGER)
  64. { "extdebug", &debugging_mode, shopt_set_debug_mode },
  65. --- 202,206 ----
  66. { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
  67. { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
  68. ! { "expand_aliases", &expaliases_flag, shopt_set_expaliases },
  69. #if defined (DEBUGGER)
  70. { "extdebug", &debugging_mode, shopt_set_debug_mode },
  71. ***************
  72. *** 351,355 ****
  73. allow_null_glob_expansion = glob_dot_filenames = 0;
  74. no_exit_on_failed_exec = 0;
  75. ! expand_aliases = 0;
  76. extended_quote = 1;
  77. fail_glob_expansion = 0;
  78. --- 354,358 ----
  79. allow_null_glob_expansion = glob_dot_filenames = 0;
  80. no_exit_on_failed_exec = 0;
  81. ! expand_aliases = expaliases_flag = 0;
  82. extended_quote = 1;
  83. fail_glob_expansion = 0;
  84. ***************
  85. *** 632,635 ****
  86. --- 635,647 ----
  87. }
  88. + static int
  89. + shopt_set_expaliases (option_name, mode)
  90. + char *option_name;
  91. + int mode;
  92. + {
  93. + expand_aliases = expaliases_flag;
  94. + return 0;
  95. + }
  96. +
  97. #if defined (READLINE)
  98. static int
  99. *** ../bash-20221007/builtins/common.h 2022-10-07 10:10:17.000000000 -0400
  100. --- builtins/common.h 2022-10-14 09:29:25.000000000 -0400
  101. ***************
  102. *** 258,261 ****
  103. --- 258,263 ----
  104. #endif
  105. + extern int expaliases_flag;
  106. +
  107. /* variables from source.def */
  108. extern int source_searches_cwd;
  109. *** ../bash-20221007/execute_cmd.c 2022-10-10 10:48:54.000000000 -0400
  110. --- execute_cmd.c 2022-10-14 09:32:24.000000000 -0400
  111. ***************
  112. *** 1537,1541 ****
  113. aliases. */
  114. if (ois != interactive_shell)
  115. ! expand_aliases = 0;
  116. }
  117. --- 1537,1541 ----
  118. aliases. */
  119. if (ois != interactive_shell)
  120. ! expand_aliases = expaliases_flag = 0;
  121. }
  122. *** ../bash-20221007/general.c 2021-11-04 14:12:38.000000000 -0400
  123. --- general.c 2022-10-14 09:34:24.000000000 -0400
  124. ***************
  125. *** 92,96 ****
  126. &interactive_comments,
  127. &source_uses_path,
  128. ! &expand_aliases,
  129. &inherit_errexit,
  130. &print_shift_error,
  131. --- 92,96 ----
  132. &interactive_comments,
  133. &source_uses_path,
  134. ! &expaliases_flag,
  135. &inherit_errexit,
  136. &print_shift_error,
  137. ***************
  138. *** 107,111 ****
  139. if (on != 0)
  140. {
  141. ! interactive_comments = source_uses_path = expand_aliases = 1;
  142. inherit_errexit = 1;
  143. source_searches_cwd = 0;
  144. --- 107,112 ----
  145. if (on != 0)
  146. {
  147. ! interactive_comments = source_uses_path = 1;
  148. ! expand_aliases = expaliases_flag = 1;
  149. inherit_errexit = 1;
  150. source_searches_cwd = 0;
  151. ***************
  152. *** 117,120 ****
  153. --- 118,122 ----
  154. {
  155. set_posix_options (saved_posix_vars);
  156. + expand_aliases = expaliases_flag;
  157. free (saved_posix_vars);
  158. saved_posix_vars = 0;
  159. ***************
  160. *** 123,127 ****
  161. {
  162. source_searches_cwd = 1;
  163. ! expand_aliases = interactive_shell;
  164. print_shift_error = 0;
  165. }
  166. --- 125,129 ----
  167. {
  168. source_searches_cwd = 1;
  169. ! expand_aliases = expaliases_flag = interactive_shell; /* XXX */
  170. print_shift_error = 0;
  171. }
  172. *** ../bash-5.2-patched/shell.c 2022-03-04 15:13:00.000000000 -0500
  173. --- shell.c 2022-10-14 09:36:19.000000000 -0400
  174. ***************
  175. *** 1845,1850 ****
  176. init_interactive ()
  177. {
  178. ! expand_aliases = interactive_shell = startup_state = 1;
  179. ! interactive = 1;
  180. #if defined (HISTORY)
  181. if (enable_history_list == -1)
  182. --- 1845,1850 ----
  183. init_interactive ()
  184. {
  185. ! expand_aliases = expaliases_flag = 1;
  186. ! interactive_shell = startup_state = interactive = 1;
  187. #if defined (HISTORY)
  188. if (enable_history_list == -1)
  189. ***************
  190. *** 1866,1870 ****
  191. #endif /* HISTORY */
  192. interactive_shell = startup_state = interactive = 0;
  193. ! expand_aliases = posixly_correct; /* XXX - was 0 not posixly_correct */
  194. no_line_editing = 1;
  195. #if defined (JOB_CONTROL)
  196. --- 1866,1870 ----
  197. #endif /* HISTORY */
  198. interactive_shell = startup_state = interactive = 0;
  199. ! expand_aliases = expaliases_flag = posixly_correct; /* XXX - was 0 not posixly_correct */
  200. no_line_editing = 1;
  201. #if defined (JOB_CONTROL)
  202. ***************
  203. *** 1883,1887 ****
  204. #endif
  205. init_noninteractive ();
  206. ! expand_aliases = interactive_shell = startup_state = 1;
  207. #if defined (HISTORY)
  208. remember_on_history = enable_history_list; /* XXX */
  209. --- 1883,1887 ----
  210. #endif
  211. init_noninteractive ();
  212. ! expand_aliases = expaliases_flag = interactive_shell = startup_state = 1;
  213. #if defined (HISTORY)
  214. remember_on_history = enable_history_list; /* XXX */
  215. ***************
  216. *** 2026,2030 ****
  217. forced_interactive = interactive_shell = 0;
  218. subshell_environment = running_in_background = 0;
  219. ! expand_aliases = 0;
  220. bash_argv_initialized = 0;
  221. --- 2026,2030 ----
  222. forced_interactive = interactive_shell = 0;
  223. subshell_environment = running_in_background = 0;
  224. ! expand_aliases = expaliases_flag = 0;
  225. bash_argv_initialized = 0;
  226. *** ../bash-5.2-patched/y.tab.c 2022-09-23 10:18:27.000000000 -0400
  227. --- y.tab.c 2022-10-14 14:57:26.000000000 -0400
  228. ***************
  229. *** 5618,5621 ****
  230. --- 5618,5623 ----
  231. extended_glob = global_extglob;
  232. #endif
  233. + if (parser_state & (PST_CMDSUBST|PST_STRING))
  234. + expand_aliases = expaliases_flag;
  235. parser_state = 0;
  236. ***************
  237. *** 6700,6703 ****
  238. --- 6702,6706 ----
  239. parser_state |= PST_NOERROR;
  240. + parser_state |= PST_STRING;
  241. expand_aliases = 0;
  242. ***************
  243. *** 8713,8717 ****
  244. parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
  245. /* State flags we want to set for this run through the tokenizer. */
  246. ! parser_state |= PST_COMPASSIGN|PST_REPARSE;
  247. }
  248. --- 8716,8720 ----
  249. parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
  250. /* State flags we want to set for this run through the tokenizer. */
  251. ! parser_state |= PST_COMPASSIGN|PST_REPARSE|PST_STRING;
  252. }
  253. *** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
  254. --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
  255. ***************
  256. *** 26,30 ****
  257. looks for to find the patch level (for the sccs version string). */
  258. ! #define PATCHLEVEL 5
  259. #endif /* _PATCHLEVEL_H_ */
  260. --- 26,30 ----
  261. looks for to find the patch level (for the sccs version string). */
  262. ! #define PATCHLEVEL 6
  263. #endif /* _PATCHLEVEL_H_ */