7 Bug-Reported-by: feng xiangjun <fengxj325@gmail.com>
8 Bug-Reference-ID: <CAHH2t87LrCmO=gdyWOmGn5WJt7EucL+iOXzrry34OETe50S6uA@mail.gmail.com>
9 Bug-Reference-URL: https://lists.gnu.org/archive/html/bug-bash/2022-10/msg00089.html
13 In interactive shells, interrupting the shell while entering a command
14 substitution can inhibit alias expansion.
16 Patch (apply with `patch -p0'):
18 *** ../bash-5.2-patched/parse.y 2022-10-08 13:10:06.000000000 -0400
19 --- parse.y 2022-10-14 10:03:19.000000000 -0400
23 extended_glob = global_extglob;
25 + if (parser_state & (PST_CMDSUBST|PST_STRING))
26 + expand_aliases = expaliases_flag;
32 parser_state |= PST_NOERROR;
34 + parser_state |= PST_STRING;
39 parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
40 /* State flags we want to set for this run through the tokenizer. */
41 ! parser_state |= PST_COMPASSIGN|PST_REPARSE;
45 parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
46 /* State flags we want to set for this run through the tokenizer. */
47 ! parser_state |= PST_COMPASSIGN|PST_REPARSE|PST_STRING;
50 *** ../bash-20221007/parser.h 2022-08-30 11:39:56.000000000 -0400
51 --- parser.h 2022-10-14 09:56:18.000000000 -0400
55 #define PST_NOEXPAND 0x400000 /* don't expand anything in read_token_word; for command substitution */
56 #define PST_NOERROR 0x800000 /* don't print error messages in yyerror */
57 + #define PST_STRING 0x1000000 /* parsing a string to a command or word list */
59 /* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */
60 *** ../bash-20221007/builtins/shopt.def 2022-10-07 10:25:55.000000000 -0400
61 --- builtins/shopt.def 2022-10-14 09:30:11.000000000 -0400
67 + int expaliases_flag = 0;
68 + static int shopt_set_expaliases PARAMS((char *, int));
70 static int shopt_set_debug_mode PARAMS((char *, int));
74 { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
75 { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
76 ! { "expand_aliases", &expand_aliases, (shopt_set_func_t *)NULL },
77 #if defined (DEBUGGER)
78 { "extdebug", &debugging_mode, shopt_set_debug_mode },
80 { "dotglob", &glob_dot_filenames, (shopt_set_func_t *)NULL },
81 { "execfail", &no_exit_on_failed_exec, (shopt_set_func_t *)NULL },
82 ! { "expand_aliases", &expaliases_flag, shopt_set_expaliases },
83 #if defined (DEBUGGER)
84 { "extdebug", &debugging_mode, shopt_set_debug_mode },
87 allow_null_glob_expansion = glob_dot_filenames = 0;
88 no_exit_on_failed_exec = 0;
91 fail_glob_expansion = 0;
93 allow_null_glob_expansion = glob_dot_filenames = 0;
94 no_exit_on_failed_exec = 0;
95 ! expand_aliases = expaliases_flag = 0;
97 fail_glob_expansion = 0;
104 + shopt_set_expaliases (option_name, mode)
108 + expand_aliases = expaliases_flag;
112 #if defined (READLINE)
114 *** ../bash-20221007/builtins/common.h 2022-10-07 10:10:17.000000000 -0400
115 --- builtins/common.h 2022-10-14 09:29:25.000000000 -0400
121 + extern int expaliases_flag;
123 /* variables from source.def */
124 extern int source_searches_cwd;
125 *** ../bash-20221007/execute_cmd.c 2022-10-10 10:48:54.000000000 -0400
126 --- execute_cmd.c 2022-10-14 09:32:24.000000000 -0400
130 if (ois != interactive_shell)
131 ! expand_aliases = 0;
136 if (ois != interactive_shell)
137 ! expand_aliases = expaliases_flag = 0;
140 *** ../bash-20221007/general.c 2021-11-04 14:12:38.000000000 -0400
141 --- general.c 2022-10-14 09:34:24.000000000 -0400
144 &interactive_comments,
150 &interactive_comments,
159 ! interactive_comments = source_uses_path = expand_aliases = 1;
161 source_searches_cwd = 0;
165 ! interactive_comments = source_uses_path = 1;
166 ! expand_aliases = expaliases_flag = 1;
168 source_searches_cwd = 0;
173 set_posix_options (saved_posix_vars);
174 + expand_aliases = expaliases_flag;
175 free (saved_posix_vars);
176 saved_posix_vars = 0;
180 source_searches_cwd = 1;
181 ! expand_aliases = interactive_shell;
182 print_shift_error = 0;
186 source_searches_cwd = 1;
187 ! expand_aliases = expaliases_flag = interactive_shell; /* XXX */
188 print_shift_error = 0;
191 *** ../bash-5.2-patched/shell.c 2022-03-04 15:13:00.000000000 -0500
192 --- shell.c 2022-10-14 09:36:19.000000000 -0400
197 ! expand_aliases = interactive_shell = startup_state = 1;
199 #if defined (HISTORY)
200 if (enable_history_list == -1)
204 ! expand_aliases = expaliases_flag = 1;
205 ! interactive_shell = startup_state = interactive = 1;
206 #if defined (HISTORY)
207 if (enable_history_list == -1)
211 interactive_shell = startup_state = interactive = 0;
212 ! expand_aliases = posixly_correct; /* XXX - was 0 not posixly_correct */
214 #if defined (JOB_CONTROL)
217 interactive_shell = startup_state = interactive = 0;
218 ! expand_aliases = expaliases_flag = posixly_correct; /* XXX - was 0 not posixly_correct */
220 #if defined (JOB_CONTROL)
224 init_noninteractive ();
225 ! expand_aliases = interactive_shell = startup_state = 1;
226 #if defined (HISTORY)
227 remember_on_history = enable_history_list; /* XXX */
230 init_noninteractive ();
231 ! expand_aliases = expaliases_flag = interactive_shell = startup_state = 1;
232 #if defined (HISTORY)
233 remember_on_history = enable_history_list; /* XXX */
236 forced_interactive = interactive_shell = 0;
237 subshell_environment = running_in_background = 0;
238 ! expand_aliases = 0;
239 bash_argv_initialized = 0;
242 forced_interactive = interactive_shell = 0;
243 subshell_environment = running_in_background = 0;
244 ! expand_aliases = expaliases_flag = 0;
245 bash_argv_initialized = 0;
247 *** ../bash-5.2-patched/y.tab.c 2022-09-23 10:18:27.000000000 -0400
248 --- y.tab.c 2022-10-14 14:57:26.000000000 -0400
252 extended_glob = global_extglob;
254 + if (parser_state & (PST_CMDSUBST|PST_STRING))
255 + expand_aliases = expaliases_flag;
261 parser_state |= PST_NOERROR;
263 + parser_state |= PST_STRING;
268 parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
269 /* State flags we want to set for this run through the tokenizer. */
270 ! parser_state |= PST_COMPASSIGN|PST_REPARSE;
274 parser_state &= ~PST_NOEXPAND; /* parse_comsub sentinel */
275 /* State flags we want to set for this run through the tokenizer. */
276 ! parser_state |= PST_COMPASSIGN|PST_REPARSE|PST_STRING;
279 *** ../bash-5.2/patchlevel.h 2020-06-22 14:51:03.000000000 -0400
280 --- patchlevel.h 2020-10-01 11:01:28.000000000 -0400
283 looks for to find the patch level (for the sccs version string). */
285 ! #define PATCHLEVEL 5
287 #endif /* _PATCHLEVEL_H_ */
289 looks for to find the patch level (for the sccs version string). */
291 ! #define PATCHLEVEL 6
293 #endif /* _PATCHLEVEL_H_ */