summary refs log tree commit diff
path: root/src/parser.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/parser.c')
-rw-r--r--src/parser.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/parser.c b/src/parser.c
index 2d20b00..3206328 100644
--- a/src/parser.c
+++ b/src/parser.c
@@ -64,6 +64,11 @@
 
 
 
+/* Used by expandstr to get here-doc like behaviour. */
+#define FAKEEOFMARK (char *)1
+
+
+
 struct heredoc {
 	struct heredoc *next;	/* next here document in list */
 	union node *here;		/* redirection node */
@@ -113,6 +118,11 @@ isassignment(const char *p)
 	return *q == '=';
 }
 
+static inline int realeofmark(const char *eofmark)
+{
+	return eofmark && eofmark != FAKEEOFMARK;
+}
+
 
 /*
  * Read and parse a command.  Returns NEOF on end of file.  (NULL is a
@@ -1030,7 +1040,7 @@ endword:
  */
 
 checkend: {
-	if (eofmark) {
+	if (realeofmark(eofmark)) {
 		int markloc;
 		char *p;
 
@@ -1492,7 +1502,7 @@ expandstr(const char *ps)
 
 	/* XXX Fix (char *) cast. */
 	setinputstring((char *)ps);
-	readtoken1(pgetc(), DQSYNTAX, nullstr, 0);
+	readtoken1(pgetc(), DQSYNTAX, FAKEEOFMARK, 0);
 	popfile();
 
 	n.narg.type = NARG;