1
0
Fork 0
mirror of synced 2025-03-06 20:53:29 +01:00

Bash-5.0 patch 2: fix expansion of aliases whose value ends with an unquoted tab

This commit is contained in:
Chet Ramey 2019-01-18 15:13:57 -05:00
parent 4d2e315490
commit ddf3f643cb
4 changed files with 10 additions and 3 deletions

View file

@ -2557,12 +2557,14 @@ next_alias_char:
if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE &&
pushed_string_list->flags != PSH_DPAREN &&
(parser_state & PST_COMMENT) == 0 &&
(parser_state & PST_ENDALIAS) == 0 && /* only once */
shell_input_line_index > 0 &&
shell_input_line[shell_input_line_index-1] != ' ' &&
shellblank (shell_input_line[shell_input_line_index-1]) == 0 &&
shell_input_line[shell_input_line_index-1] != '\n' &&
shellmeta (shell_input_line[shell_input_line_index-1]) == 0 &&
(current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"'))
{
parser_state |= PST_ENDALIAS;
return ' '; /* END_ALIAS */
}
#endif
@ -2571,6 +2573,7 @@ pop_alias:
/* This case works for PSH_DPAREN as well */
if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
{
parser_state &= ~PST_ENDALIAS;
pop_string ();
uc = shell_input_line[shell_input_line_index];
if (uc)

View file

@ -47,6 +47,7 @@
#define PST_REPARSE 0x040000 /* re-parsing in parse_string_to_word_list */
#define PST_REDIRLIST 0x080000 /* parsing a list of redirections preceding a simple command name */
#define PST_COMMENT 0x100000 /* parsing a shell comment; used by aliases */
#define PST_ENDALIAS 0x200000 /* just finished expanding and consuming an alias */
/* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */
struct dstack {

View file

@ -25,6 +25,6 @@
regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
looks for to find the patch level (for the sccs version string). */
#define PATCHLEVEL 1
#define PATCHLEVEL 2
#endif /* _PATCHLEVEL_H_ */

View file

@ -4873,12 +4873,14 @@ next_alias_char:
if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE &&
pushed_string_list->flags != PSH_DPAREN &&
(parser_state & PST_COMMENT) == 0 &&
(parser_state & PST_ENDALIAS) == 0 && /* only once */
shell_input_line_index > 0 &&
shell_input_line[shell_input_line_index-1] != ' ' &&
shellblank (shell_input_line[shell_input_line_index-1]) == 0 &&
shell_input_line[shell_input_line_index-1] != '\n' &&
shellmeta (shell_input_line[shell_input_line_index-1]) == 0 &&
(current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"'))
{
parser_state |= PST_ENDALIAS;
return ' '; /* END_ALIAS */
}
#endif
@ -4887,6 +4889,7 @@ pop_alias:
/* This case works for PSH_DPAREN as well */
if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
{
parser_state &= ~PST_ENDALIAS;
pop_string ();
uc = shell_input_line[shell_input_line_index];
if (uc)