]> git.ipfire.org Git - ipfire-3.x.git/blame - bash/patches/bash-5.0-patch-2.patch
git: Update to 2.23.0
[ipfire-3.x.git] / bash / patches / bash-5.0-patch-2.patch
CommitLineData
6d9201b0
SS
1From ddf3f643cb9b9a2ca8e6d996c605e4332204874c Mon Sep 17 00:00:00 2001
2From: Chet Ramey <chet.ramey@case.edu>
3Date: Fri, 18 Jan 2019 15:13:57 -0500
4Subject: [PATCH] Bash-5.0 patch 2: fix expansion of aliases whose value ends
5 with an unquoted tab
6
7---
8 parse.y | 5 ++++-
9 parser.h | 1 +
10 patchlevel.h | 2 +-
11 y.tab.c | 5 ++++-
12 4 files changed, 10 insertions(+), 3 deletions(-)
13
14diff --git a/parse.y b/parse.y
15index 3ff87bcc..07e6e3e4 100644
16--- a/parse.y
17+++ b/parse.y
18@@ -2557,12 +2557,14 @@ next_alias_char:
19 if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE &&
20 pushed_string_list->flags != PSH_DPAREN &&
21 (parser_state & PST_COMMENT) == 0 &&
22+ (parser_state & PST_ENDALIAS) == 0 && /* only once */
23 shell_input_line_index > 0 &&
24- shell_input_line[shell_input_line_index-1] != ' ' &&
25+ shellblank (shell_input_line[shell_input_line_index-1]) == 0 &&
26 shell_input_line[shell_input_line_index-1] != '\n' &&
27 shellmeta (shell_input_line[shell_input_line_index-1]) == 0 &&
28 (current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"'))
29 {
30+ parser_state |= PST_ENDALIAS;
31 return ' '; /* END_ALIAS */
32 }
33 #endif
34@@ -2571,6 +2573,7 @@ pop_alias:
35 /* This case works for PSH_DPAREN as well */
36 if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
37 {
38+ parser_state &= ~PST_ENDALIAS;
39 pop_string ();
40 uc = shell_input_line[shell_input_line_index];
41 if (uc)
42diff --git a/parser.h b/parser.h
43index 54dd2c88..6d08915d 100644
44--- a/parser.h
45+++ b/parser.h
46@@ -47,6 +47,7 @@
47 #define PST_REPARSE 0x040000 /* re-parsing in parse_string_to_word_list */
48 #define PST_REDIRLIST 0x080000 /* parsing a list of redirections preceding a simple command name */
49 #define PST_COMMENT 0x100000 /* parsing a shell comment; used by aliases */
50+#define PST_ENDALIAS 0x200000 /* just finished expanding and consuming an alias */
51
52 /* Definition of the delimiter stack. Needed by parse.y and bashhist.c. */
53 struct dstack {
54diff --git a/patchlevel.h b/patchlevel.h
55index 40db1a32..a988d852 100644
56--- a/patchlevel.h
57+++ b/patchlevel.h
58@@ -25,6 +25,6 @@
59 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
60 looks for to find the patch level (for the sccs version string). */
61
62-#define PATCHLEVEL 1
63+#define PATCHLEVEL 2
64
65 #endif /* _PATCHLEVEL_H_ */
66diff --git a/y.tab.c b/y.tab.c
67index 1abe2c50..7efce3c8 100644
68--- a/y.tab.c
69+++ b/y.tab.c
70@@ -4873,12 +4873,14 @@ next_alias_char:
71 if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE &&
72 pushed_string_list->flags != PSH_DPAREN &&
73 (parser_state & PST_COMMENT) == 0 &&
74+ (parser_state & PST_ENDALIAS) == 0 && /* only once */
75 shell_input_line_index > 0 &&
76- shell_input_line[shell_input_line_index-1] != ' ' &&
77+ shellblank (shell_input_line[shell_input_line_index-1]) == 0 &&
78 shell_input_line[shell_input_line_index-1] != '\n' &&
79 shellmeta (shell_input_line[shell_input_line_index-1]) == 0 &&
80 (current_delimiter (dstack) != '\'' && current_delimiter (dstack) != '"'))
81 {
82+ parser_state |= PST_ENDALIAS;
83 return ' '; /* END_ALIAS */
84 }
85 #endif
86@@ -4887,6 +4889,7 @@ pop_alias:
87 /* This case works for PSH_DPAREN as well */
88 if (uc == 0 && pushed_string_list && pushed_string_list->flags != PSH_SOURCE)
89 {
90+ parser_state &= ~PST_ENDALIAS;
91 pop_string ();
92 uc = shell_input_line[shell_input_line_index];
93 if (uc)
94--
952.17.2
96