branch Attitude Adjustment packages
[12.09/packages.git] / utils / bash / patches / 101-upstream-bash42-001.patch
1                              BASH PATCH REPORT
2                              =================
3
4 Bash-Release:   4.2
5 Patch-ID:       bash42-001
6
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
10
11 Bug-Description:
12
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.
15
16 Patch (apply with `patch -p0'):
17
18 --- a/subst.c
19 +++ b/subst.c
20 @@ -1379,10 +1379,12 @@ extract_dollar_brace_string (string, sin
21    slen = strlen (string + *sindex) + *sindex;
22  
23    /* The handling of dolbrace_state needs to agree with the code in parse.y:
24 -     parse_matched_pair() */
25 -  dolbrace_state = 0;
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;
34  
35    i = *sindex;
36    while (c = string[i])
37 @@ -7176,7 +7178,7 @@ parameter_brace_expand (string, indexp, 
38      {
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)
44         sindex++;
45        else
46 --- a/subst.h
47 +++ b/subst.h
48 @@ -56,6 +56,7 @@
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} */
53  
54  /* Remove backslashes which are quoting backquotes from STRING.  Modifies
55     STRING, and returns a pointer to it. */
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 0
63 +#define PATCHLEVEL 1
64  
65  #endif /* _PATCHLEVEL_H_ */