Blame SOURCES/bash-5.1-patch-4.patch

b92f7d
diff --git a/arrayfunc.c b/arrayfunc.c
b92f7d
--- a/arrayfunc.c
b92f7d
+++ b/arrayfunc.c
b92f7d
@@ -597,6 +597,27 @@ assign_assoc_from_kvlist (var, nlist, h, flags)
b92f7d
 	free (aval);
b92f7d
     }
b92f7d
 }
b92f7d
+
b92f7d
+/* Return non-zero if L appears to be a key-value pair associative array
b92f7d
+   compound assignment. */ 
b92f7d
+int
b92f7d
+kvpair_assignment_p (l)
b92f7d
+     WORD_LIST *l;
b92f7d
+{
b92f7d
+  return (l && (l->word->flags & W_ASSIGNMENT) == 0 && l->word->word[0] != '[');	/*]*/
b92f7d
+}
b92f7d
+
b92f7d
+char *
b92f7d
+expand_and_quote_kvpair_word (w)
b92f7d
+     char *w;
b92f7d
+{
b92f7d
+  char *t, *r;
b92f7d
+
b92f7d
+  t = w ? expand_assignment_string_to_string (w, 0) : 0;
b92f7d
+  r = sh_single_quote (t ? t : "");
b92f7d
+  free (t);
b92f7d
+  return r;
b92f7d
+}
b92f7d
 #endif
b92f7d
      
b92f7d
 /* Callers ensure that VAR is not NULL. Associative array assignments have not
b92f7d
@@ -640,7 +661,7 @@ assign_compound_array_list (var, nlist, flags)
b92f7d
   last_ind = (a && (flags & ASS_APPEND)) ? array_max_index (a) + 1 : 0;
b92f7d
 
b92f7d
 #if ASSOC_KVPAIR_ASSIGNMENT
b92f7d
-  if (assoc_p (var) && nlist && (nlist->word->flags & W_ASSIGNMENT) == 0 && nlist->word->word[0] != '[')	/*]*/
b92f7d
+  if (assoc_p (var) && kvpair_assignment_p (nlist))
b92f7d
     {
b92f7d
       iflags = flags & ~ASS_APPEND;
b92f7d
       assign_assoc_from_kvlist (var, nlist, nhash, iflags);
b92f7d
diff --git a/arrayfunc.h b/arrayfunc.h
b92f7d
--- a/arrayfunc.h
b92f7d
+++ b/arrayfunc.h
b92f7d
@@ -67,6 +67,9 @@ extern SHELL_VAR *assign_array_var_from_string PARAMS((SHELL_VAR *, char *, int)
b92f7d
 extern char *expand_and_quote_assoc_word PARAMS((char *, int));
b92f7d
 extern void quote_compound_array_list PARAMS((WORD_LIST *, int));
b92f7d
 
b92f7d
+extern int kvpair_assignment_p PARAMS((WORD_LIST *));
b92f7d
+extern char *expand_and_quote_kvpair_word PARAMS((char *));
b92f7d
+
b92f7d
 extern int unbind_array_element PARAMS((SHELL_VAR *, char *, int));
b92f7d
 extern int skipsubscript PARAMS((const char *, int, int));
b92f7d
 
b92f7d
diff --git a/patchlevel.h b/patchlevel.h
b92f7d
--- a/patchlevel.h
b92f7d
+++ b/patchlevel.h
b92f7d
@@ -25,6 +25,6 @@
b92f7d
    regexp `^#define[ 	]*PATCHLEVEL', since that's what support/mkversion.sh
b92f7d
    looks for to find the patch level (for the sccs version string). */
b92f7d
 
b92f7d
-#define PATCHLEVEL 3
b92f7d
+#define PATCHLEVEL 4
b92f7d
 
b92f7d
 #endif /* _PATCHLEVEL_H_ */
b92f7d
diff --git a/subst.c b/subst.c
b92f7d
--- a/subst.c
b92f7d
+++ b/subst.c
b92f7d
@@ -11604,6 +11604,7 @@ expand_oneword (value, flags)
b92f7d
 {
b92f7d
   WORD_LIST *l, *nl;
b92f7d
   char *t;
b92f7d
+  int kvpair;
b92f7d
   
b92f7d
   if (flags == 0)
b92f7d
     {
b92f7d
@@ -11618,11 +11619,21 @@ expand_oneword (value, flags)
b92f7d
     {
b92f7d
       /* Associative array */
b92f7d
       l = parse_string_to_word_list (value, 1, "array assign");
b92f7d
+#if ASSOC_KVPAIR_ASSIGNMENT
b92f7d
+      kvpair = kvpair_assignment_p (l);
b92f7d
+#endif
b92f7d
+
b92f7d
       /* For associative arrays, with their arbitrary subscripts, we have to
b92f7d
 	 expand and quote in one step so we don't have to search for the
b92f7d
 	 closing right bracket more than once. */
b92f7d
       for (nl = l; nl; nl = nl->next)
b92f7d
 	{
b92f7d
+#if ASSOC_KVPAIR_ASSIGNMENT
b92f7d
+	  if (kvpair)
b92f7d
+	    /* keys and values undergo the same set of expansions */
b92f7d
+	    t = expand_and_quote_kvpair_word (nl->word->word);
b92f7d
+	  else
b92f7d
+#endif
b92f7d
 	  if ((nl->word->flags & W_ASSIGNMENT) == 0)
b92f7d
 	    t = sh_single_quote (nl->word->word ? nl->word->word : "");
b92f7d
 	  else