1 # DP: bash-4.2 upstream patch 001
9 Bug-Reported-by: Juergen Daubert <jue@jue.li>
10 Bug-Reference-ID: <20110214175132.GA19813@jue.netz>
11 Bug-Reference-URL: http://lists.gnu.org/archive/html/bug-bash/2011-02/msg00125.html
15 When running in Posix mode, bash does not correctly expand the right-hand
16 side of a double-quoted word expansion containing single quotes.
18 Patch (apply with `patch -p0'):
20 --- a/bash/patchlevel.h
21 +++ b/bash/patchlevel.h
23 regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh
24 looks for to find the patch level (for the sccs version string). */
29 #endif /* _PATCHLEVEL_H_ */
32 @@ -1379,10 +1379,12 @@
33 slen = strlen (string + *sindex) + *sindex;
35 /* The handling of dolbrace_state needs to agree with the code in parse.y:
36 - parse_matched_pair() */
38 - if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
39 - dolbrace_state = (flags & SX_POSIXEXP) ? DOLBRACE_QUOTE : DOLBRACE_PARAM;
40 + parse_matched_pair(). The different initial value is to handle the
41 + case where this function is called to parse the word in
42 + ${param op word} (SX_WORD). */
43 + dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
44 + if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
45 + dolbrace_state = DOLBRACE_QUOTE;
51 /* Extract the contents of the ${ ... } expansion
52 according to the Posix.2 rules. */
53 - value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP : 0);
54 + value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
55 if (string[sindex] == RBRACE)
61 #define SX_NOLONGJMP 0x0040 /* don't longjmp on fatal error */
62 #define SX_ARITHSUB 0x0080 /* extracting $(( ... )) (currently unused) */
63 #define SX_POSIXEXP 0x0100 /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */
64 +#define SX_WORD 0x0200 /* extracting word in ${param op word} */
66 /* Remove backslashes which are quoting backquotes from STRING. Modifies
67 STRING, and returns a pointer to it. */