]> git.ipfire.org Git - thirdparty/bash.git/commitdiff
Bash-5.3 patch 3: remove internal quoting that causes failures when expanding nested...
authorChet Ramey <chet.ramey@case.edu>
Wed, 23 Jul 2025 19:52:32 +0000 (15:52 -0400)
committerChet Ramey <chet.ramey@case.edu>
Wed, 23 Jul 2025 19:52:32 +0000 (15:52 -0400)
patchlevel.h
subst.c
tests/quotearray.right

index ceabc701711c234465d6924515a0da09c4bb6fa9..a1609dc89da6f392414d15b02bf28200c6abd172 100644 (file)
@@ -25,6 +25,6 @@
    regexp `^#define[   ]*PATCHLEVEL', since that's what support/mkversion.sh
    looks for to find the patch level (for the sccs version string). */
 
-#define PATCHLEVEL 2
+#define PATCHLEVEL 3
 
 #endif /* _PATCHLEVEL_H_ */
diff --git a/subst.c b/subst.c
index e9d3e7557484e22254e7536ea8a33857d9630817..a8ae174d5da3854fa1c0cf1f98390f76a638ac5e 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -3795,9 +3795,9 @@ pos_params (const char *string, int start, int end, int quoted, int pflags)
 #define EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~')
 #endif
 
-/* We don't perform process substitution in arithmetic expressions, so don't
-   bother checking for it. */
-#define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC || s == '~')
+/* We don't perform process substitution or tilde expansion in arithmetic
+   expressions, so don't bother checking for them. */
+#define ARITH_EXP_CHAR(s) (s == '$' || s == '`' || s == CTLESC)
 
 /* If there are any characters in STRING that require full expansion,
    then call FUNC to expand STRING; otherwise just perform quote
@@ -12215,6 +12215,14 @@ string_quote_removal (const char *string, int quoted)
              *r++ = '\\';
              break;
            }
+#if defined (ARRAY_VARS)
+         /* The only special characters that matter here are []~, since those
+            are backslash-quoted in expand_array_subscript but not dequoted
+            by the statement following this one. */
+         if ((quoted & Q_ARITH) && (c == LBRACK || c == RBRACK || c == '~'))
+           ;           /* placeholder here */
+         else
+#endif
          if (((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) || dquote) && (sh_syntaxtab[c] & CBSDQUOTE) == 0)
            *r++ = '\\';
          /* FALLTHROUGH */
index a3cc93a6b2c529fca786c2af99be3abc6c538163..a75ef52a67eeb9c38d5d81ef0e2c6edae25c0c2d 100644 (file)
@@ -44,7 +44,7 @@ declare -A assoc=(["\` echo >&2 foo\`"]="128" [0]="0" ["]"]="12" ["x],b[\$(echo
 foo
 0
 0
-./quotearray1.sub: line 68: 0\],b\[1: arithmetic syntax error: invalid arithmetic operator (error token is "\],b\[1")
+./quotearray1.sub: line 68: 0],b[1: arithmetic syntax error: invalid arithmetic operator (error token is "],b[1")
 declare -a array
 0
 0