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