about summary refs log tree commit diff
path: root/Src
diff options
context:
space:
mode:
Diffstat (limited to 'Src')
-rw-r--r--Src/exec.c3
-rw-r--r--Src/parse.c3
-rw-r--r--Src/subst.c30
3 files changed, 32 insertions, 4 deletions
diff --git a/Src/exec.c b/Src/exec.c
index 04e0e19ad..90e75db64 100644
--- a/Src/exec.c
+++ b/Src/exec.c
@@ -2714,9 +2714,10 @@ gethere(char *str, int typ)
 
     for (s = str; *s; s++)
 	if (INULL(*s)) {
-	    *s = Nularg;
 	    qt = 1;
+	    break;
 	}
+    quotesubst(str);
     untokenize(str);
     if (typ == REDIR_HEREDOCDASH) {
 	strip = 1;
diff --git a/Src/parse.c b/Src/parse.c
index 6bef195f8..0d0dc6c35 100644
--- a/Src/parse.c
+++ b/Src/parse.c
@@ -1754,9 +1754,6 @@ par_redir(int *rp)
 	if ((tokstr[0] == Inang || tokstr[0] == Outang) && tokstr[1] == Inpar)
 	    type = tokstr[0] == Inang ? REDIR_INPIPE : REDIR_OUTPIPE;
 	break;
-    case REDIR_HERESTR:
-        remnulargs(name = dupstring(name));
-        break;
     }
     yylex();
 
diff --git a/Src/subst.c b/Src/subst.c
index 189ecda6e..da3db5844 100644
--- a/Src/subst.c
+++ b/Src/subst.c
@@ -231,6 +231,36 @@ stringsubst(LinkList list, LinkNode node, int ssub, int asssub)
     return errflag ? NULL : node;
 }
 
+/*
+ * Simplified version of the prefork/singsub processing where
+ * we only do substitutions appropriate to quoting.  Currently
+ * this means only the expansions in $'....'.  This is used
+ * for the end tag for here documents.  As we are not doing
+ * `...` expansions, we just use those for quoting.  However,
+ * they stay in the text.  This is weird, but that's not
+ * my fault.
+ *
+ * The remnulargs() makes this consistent with the other forms
+ * of substitution, indicating that quotes have been fully
+ * processed.
+ */
+
+/**/
+void
+quotesubst(char *str)
+{
+    char *s = str;
+
+    while (*s) {
+	if (*s == String && s[1] == Snull) {
+	    s = getkeystring(s, NULL, 4, NULL);
+	} else {
+	    s++;
+	}
+    }
+    remnulargs(str);
+}
+
 /**/
 mod_export void
 globlist(LinkList list, int nountok)