]> git.ipfire.org Git - thirdparty/bash.git/blobdiff - subst.c
Bash-4.2 patch 34
[thirdparty/bash.git] / subst.c
diff --git a/subst.c b/subst.c
index c9a06788f905c074710b7538a6c78a49abaa5360..19151201e9b523ead11cb86d9350a82d8bef7274 100644 (file)
--- a/subst.c
+++ b/subst.c
@@ -4166,7 +4166,7 @@ match_wpattern (wstring, indices, wstrlen, wpat, mtype, sp, ep)
   simple = (wpat[0] != L'\\' && wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'[');
 #if defined (EXTENDED_GLOB)
   if (extended_glob)
-    simple |= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
+    simple &= (wpat[1] != L'(' || (wpat[0] != L'*' && wpat[0] != L'?' && wpat[0] != L'+' && wpat[0] != L'!' && wpat[0] != L'@')); /*)*/
 #endif
 
   /* If the pattern doesn't match anywhere in the string, go ahead and
@@ -5809,6 +5809,16 @@ parameter_brace_expand_rhs (name, value, c, quoted, qdollaratp, hasdollarat)
         is the only expansion that creates more than one word. */
       if (qdollaratp && ((hasdol && quoted) || l->next))
        *qdollaratp = 1;
+      /* If we have a quoted null result (QUOTED_NULL(temp)) and the word is
+        a quoted null (l->next == 0 && QUOTED_NULL(l->word->word)), the
+        flags indicate it (l->word->flags & W_HASQUOTEDNULL), and the
+        expansion is quoted (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
+        (which is more paranoia than anything else), we need to return the
+        quoted null string and set the flags to indicate it. */
+      if (l->next == 0 && (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && QUOTED_NULL(temp) && QUOTED_NULL(l->word->word) && (l->word->flags & W_HASQUOTEDNULL))
+       {
+         w->flags |= W_HASQUOTEDNULL;
+       }
       dispose_words (l);
     }
   else if ((quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES)) && hasdol)
@@ -8141,6 +8151,14 @@ add_string:
          temp = tword->word;
          dispose_word_desc (tword);
 
+         /* Kill quoted nulls; we will add them back at the end of
+            expand_word_internal if nothing else in the string */
+         if (had_quoted_null && temp && QUOTED_NULL (temp))
+           {
+             FREE (temp);
+             temp = (char *)NULL;
+           }
+
          goto add_string;
          break;
 
@@ -8545,7 +8563,7 @@ finished_with_string:
        tword->flags |= W_NOEXPAND;     /* XXX */
       if (quoted & (Q_HERE_DOCUMENT|Q_DOUBLE_QUOTES))
        tword->flags |= W_QUOTED;
-      if (had_quoted_null)
+      if (had_quoted_null && QUOTED_NULL (istring))
        tword->flags |= W_HASQUOTEDNULL;
       list = make_word_list (tword, (WORD_LIST *)NULL);
     }
@@ -8576,7 +8594,7 @@ finished_with_string:
            tword->flags |= W_NOGLOB;
          if (word->flags & W_NOEXPAND)
            tword->flags |= W_NOEXPAND;
-         if (had_quoted_null)
+         if (had_quoted_null && QUOTED_NULL (istring))
            tword->flags |= W_HASQUOTEDNULL;    /* XXX */
          list = make_word_list (tword, (WORD_LIST *)NULL);
        }