|
| 1 | +From 25c37d4804a9dbe0824ba805cc2b7cb94d243682 Mon Sep 17 00:00:00 2001 |
| 2 | +From: Chet Ramey <chet.ramey@case.edu> |
| 3 | +Date: Wed, 23 Jul 2025 15:52:32 -0400 |
| 4 | +Subject: Bash-5.3 patch 3: remove internal quoting that causes failures when |
| 5 | + expanding nested array subscripts in an arithmetic context |
| 6 | + |
| 7 | +--- a/patchlevel.h |
| 8 | ++++ b/patchlevel.h |
| 9 | +@@ -25,6 +25,6 @@ |
| 10 | + regexp `^#define[ ]*PATCHLEVEL', since that's what support/mkversion.sh |
| 11 | + looks for to find the patch level (for the sccs version string). */ |
| 12 | + |
| 13 | +-#define PATCHLEVEL 2 |
| 14 | ++#define PATCHLEVEL 3 |
| 15 | + |
| 16 | + #endif /* _PATCHLEVEL_H_ */ |
| 17 | +--- a/subst.c |
| 18 | ++++ b/subst.c |
| 19 | +@@ -3795,9 +3795,9 @@ pos_params (const char *string, int star |
| 20 | + #define EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~') |
| 21 | + #endif |
| 22 | + |
| 23 | +-/* We don't perform process substitution in arithmetic expressions, so don't |
| 24 | +- bother checking for it. */ |
| 25 | +-#define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~') |
| 26 | ++/* We don't perform process substitution or tilde expansion in arithmetic |
| 27 | ++ expressions, so don't bother checking for them. */ |
| 28 | ++#define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC) |
| 29 | + |
| 30 | + /* If there are any characters in STRING that require full expansion, |
| 31 | + then call FUNC to expand STRING; otherwise just perform quote |
| 32 | +@@ -12215,6 +12215,14 @@ string_quote_removal (const char *string |
| 33 | + *r++ = '\\'; |
| 34 | + break; |
| 35 | + } |
| 36 | ++#if defined (ARRAY_VARS) |
| 37 | ++ /* The only special characters that matter here are []~, since those |
| 38 | ++ are backslash-quoted in expand_array_subscript but not dequoted |
| 39 | ++ by the statement following this one. */ |
| 40 | ++ if ((quoted & Q_ARITH) && (c == LBRACK || c == RBRACK || c == '~')) |
| 41 | ++ ; /* placeholder here */ |
| 42 | ++ else |
| 43 | ++#endif |
| 44 | + if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0) |
| 45 | + *r++ = '\\'; |
| 46 | + /* FALLTHROUGH */ |
| 47 | +--- a/tests/quotearray.right |
| 48 | ++++ b/tests/quotearray.right |
| 49 | +@@ -44,7 +44,7 @@ declare -A assoc=(["\` echo >&2 foo\`"]= |
| 50 | + foo |
| 51 | + 0 |
| 52 | + 0 |
| 53 | +-./quotearray1.sub: line 68: 0\],b\[1: arithmetic syntax error: invalid arithmetic operator (error token is "\],b\[1") |
| 54 | ++./quotearray1.sub: line 68: 0],b[1: arithmetic syntax error: invalid arithmetic operator (error token is "],b[1") |
| 55 | + declare -a array |
| 56 | + 0 |
| 57 | + 0 |
0 commit comments