ash: parser: Do not push token back before parseheredoc
[oweals/busybox.git] / shell / ash.c
index 83cac3fb0a5eb315bacc52a6930829a717a298ba..5fb67c0fa18f316f23ec8643b24e328a05b9c3dc 100644 (file)
@@ -11607,7 +11607,7 @@ list(int nlflag)
 
        n1 = NULL;
        for (;;) {
-               switch (peektoken()) {
+               switch (readtoken()) {
                case TNL:
                        if (!(nlflag & 1))
                                break;
@@ -11618,9 +11618,12 @@ list(int nlflag)
                        if (!n1 && (nlflag & 1))
                                n1 = NODE_EOF;
                        parseheredoc();
+                       tokpushback++;
+                       lasttoken = TEOF;
                        return n1;
                }
 
+               tokpushback++;
                checkkwd = CHKNL | CHKKWD | CHKALIAS;
                if (nlflag == 2 && ((1 << peektoken()) & tokendlist))
                        return n1;