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'):
18 *** ../bash-4.2-patched/subst.c 2011-01-02 16:12:51.000000000 -0500
19 --- subst.c 2011-02-19 00:00:00.000000000 -0500
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;
32 /* The handling of dolbrace_state needs to agree with the code in parse.y:
33 ! parse_matched_pair(). The different initial value is to handle the
34 ! case where this function is called to parse the word in
35 ! ${param op word} (SX_WORD). */
36 ! dolbrace_state = (flags & SX_WORD) ? DOLBRACE_WORD : DOLBRACE_PARAM;
37 ! if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && (flags & SX_POSIXEXP))
38 ! dolbrace_state = DOLBRACE_QUOTE;
43 /* Extract the contents of the ${ ... } expansion
44 according to the Posix.2 rules. */
45 ! value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#') ? SX_POSIXEXP : 0);
46 if (string[sindex] == RBRACE)
49 /* Extract the contents of the ${ ... } expansion
50 according to the Posix.2 rules. */
51 ! value = extract_dollar_brace_string (string, &sindex, quoted, (c == '%' || c == '#' || c =='/' || c == '^' || c == ',' || c ==':') ? SX_POSIXEXP|SX_WORD : SX_WORD);
52 if (string[sindex] == RBRACE)
54 *** ../bash-4.2-patched/subst.h 2010-12-02 20:21:29.000000000 -0500
55 --- subst.h 2011-02-16 21:12:09.000000000 -0500
59 #define SX_ARITHSUB 0x0080 /* extracting $(( ... )) (currently unused) */
60 #define SX_POSIXEXP 0x0100 /* extracting new Posix pattern removal expansions in extract_dollar_brace_string */
61 + #define SX_WORD 0x0200 /* extracting word in ${param op word} */
63 /* Remove backslashes which are quoting backquotes from STRING. Modifies
64 *** ../bash-4.2-patched/patchlevel.h Sat Jun 12 20:14:48 2010
65 --- patchlevel.h Thu Feb 24 21:41:34 2011
68 looks for to find the patch level (for the sccs version string). */
70 ! #define PATCHLEVEL 0
72 #endif /* _PATCHLEVEL_H_ */
74 looks for to find the patch level (for the sccs version string). */
76 ! #define PATCHLEVEL 1
78 #endif /* _PATCHLEVEL_H_ */