]> git.pld-linux.org Git - packages/bash.git/blame - bash31-010
- 3.1 patchlevel 017
[packages/bash.git] / bash31-010
CommitLineData
6e5277ed
ER
1 BASH PATCH REPORT
2 =================
3
4Bash-Release: 3.1
5Patch-ID: bash31-010
6
7Bug-Reported-by: vw@vonwolff.de
8Bug-Reference-ID: <20060123135234.1AC2F1D596@wst07.vonwolff.de>
9Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2006-01/msg00090.html
10
11Bug-Description:
12
13There is a difference in behavior between bash-3.0 and bash-3.1 involving
14parsing of single- and double-quoted strings occurring in old-style
15command substitution. The difference has to do with how backslashes are
16processed. This patch restores a measure of backwards compatibility while
17the question of POSIX conformance and ultimately correct behavior is discussed.
18
19THIS IS AN UPDATED PATCH. USE THIS COMMAND TO REVERSE THE EFFECTS OF
20THE ORIGINAL PATCH. THE CURRENT DIRECTORY MUST BE THE BASH-3.1 SOURCE
21DIRECTORY.
22
23patch -p0 -R < bash31-010.orig
24
25Then apply this patch as usual.
26
27Patch:
28
29*** ../bash-3.1/parse.y Fri Nov 11 23:14:18 2005
30--- parse.y Thu Feb 23 08:21:12 2006
31***************
32*** 2716,2721 ****
33--- 2723,2729 ----
34 #define P_ALLOWESC 0x02
35 #define P_DQUOTE 0x04
36 #define P_COMMAND 0x08 /* parsing a command, so look for comments */
37+ #define P_BACKQUOTE 0x10 /* parsing a backquoted command substitution */
38
39 static char matched_pair_error;
40 static char *
41***************
42*** 2725,2736 ****
43 int *lenp, flags;
44 {
45 int count, ch, was_dollar, in_comment, check_comment;
46! int pass_next_character, nestlen, ttranslen, start_lineno;
47 char *ret, *nestret, *ttrans;
48 int retind, retsize, rflags;
49
50 count = 1;
51! pass_next_character = was_dollar = in_comment = 0;
52 check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
53
54 /* RFLAGS is the set of flags we want to pass to recursive calls. */
55--- 2733,2744 ----
56 int *lenp, flags;
57 {
58 int count, ch, was_dollar, in_comment, check_comment;
59! int pass_next_character, backq_backslash, nestlen, ttranslen, start_lineno;
60 char *ret, *nestret, *ttrans;
61 int retind, retsize, rflags;
62
63 count = 1;
64! pass_next_character = backq_backslash = was_dollar = in_comment = 0;
65 check_comment = (flags & P_COMMAND) && qc != '\'' && qc != '"' && (flags & P_DQUOTE) == 0;
66
67 /* RFLAGS is the set of flags we want to pass to recursive calls. */
68***************
69*** 2742,2752 ****
70 start_lineno = line_number;
71 while (count)
72 {
73! #if 0
74! ch = shell_getc ((qc != '\'' || (flags & P_ALLOWESC)) && pass_next_character == 0);
75! #else
76! ch = shell_getc (qc != '\'' && pass_next_character == 0);
77! #endif
78 if (ch == EOF)
79 {
80 free (ret);
81--- 2750,2757 ----
82 start_lineno = line_number;
83 while (count)
84 {
85! ch = shell_getc (qc != '\'' && pass_next_character == 0 && backq_backslash == 0);
86!
87 if (ch == EOF)
88 {
89 free (ret);
90***************
91*** 2771,2779 ****
92 continue;
93 }
94 /* Not exactly right yet */
95! else if (check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind -1])))
96 in_comment = 1;
97
98 if (pass_next_character) /* last char was backslash */
99 {
100 pass_next_character = 0;
101--- 2776,2791 ----
102 continue;
103 }
104 /* Not exactly right yet */
105! else if MBTEST(check_comment && in_comment == 0 && ch == '#' && (retind == 0 || ret[retind-1] == '\n' || whitespace (ret[retind - 1])))
106 in_comment = 1;
107
108+ /* last char was backslash inside backquoted command substitution */
109+ if (backq_backslash)
110+ {
111+ backq_backslash = 0;
112+ /* Placeholder for adding special characters */
113+ }
114+
115 if (pass_next_character) /* last char was backslash */
116 {
117 pass_next_character = 0;
118***************
119*** 2814,2819 ****
120--- 2824,2831 ----
121 {
122 if MBTEST((flags & P_ALLOWESC) && ch == '\\')
123 pass_next_character++;
124+ else if MBTEST((flags & P_BACKQUOTE) && ch == '\\')
125+ backq_backslash++;
126 continue;
127 }
128
129***************
130*** 2898,2904 ****
131 }
132 else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
133 {
134! nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags);
135 goto add_nestret;
136 }
137 else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
138--- 2910,2920 ----
139 }
140 else if MBTEST(qc == '`' && (ch == '"' || ch == '\'') && in_comment == 0)
141 {
142! /* Add P_BACKQUOTE so backslash quotes the next character and
143! shell_getc does the right thing with \<newline>. We do this for
144! a measure of backwards compatibility -- it's not strictly the
145! right POSIX thing. */
146! nestret = parse_matched_pair (0, ch, ch, &nestlen, rflags|P_BACKQUOTE);
147 goto add_nestret;
148 }
149 else if MBTEST(was_dollar && (ch == '(' || ch == '{' || ch == '[')) /* ) } ] */
150*** ../bash-3.1/patchlevel.h Wed Jul 20 13:58:20 2005
151--- patchlevel.h Wed Dec 7 13:48:42 2005
152***************
153*** 26,30 ****
154 looks for to find the patch level (for the sccs version string). */
155
156! #define PATCHLEVEL 9
157
158 #endif /* _PATCHLEVEL_H_ */
159--- 26,30 ----
160 looks for to find the patch level (for the sccs version string). */
161
162! #define PATCHLEVEL 10
163
164 #endif /* _PATCHLEVEL_H_ */
This page took 0.300382 seconds and 4 git commands to generate.