diff --git a/sh.c b/sh.c index 2d5565fc..181a7be2 100644 --- a/sh.c +++ b/sh.c @@ -1100,7 +1100,9 @@ main(int argc, char **argv) if (adrof(STRedit)) unsetv(STRedit); editing = 0; - } + pchrs = ";&\n"; + } else + pchrs = ";&\n#"; intty |= intact; #ifndef convex if (intty || (intact && isatty(SHOUT))) { diff --git a/sh.h b/sh.h index 19bf10d6..c941fa4b 100644 --- a/sh.h +++ b/sh.h @@ -1305,5 +1305,6 @@ extern int filec; #define TEXP_IGNORE 1 /* in ignore, it means to ignore value, just parse */ #define TEXP_NOGLOB 2 /* in ignore, it means not to globone */ +extern char *pchrs; #endif /* _h_sh */ diff --git a/sh.lex.c b/sh.lex.c index dbb2c2df..93357eaa 100644 --- a/sh.lex.c +++ b/sh.lex.c @@ -319,8 +319,15 @@ word(int parsehtime) goto ret; case '#': - if (intty || (enterhist && !parsehtime)) + if (enterhist && !parsehtime) break; + if (intty) { + do + Strbuf_append1(&wbuf, c); + while ((c = getC(0)) != CHAR_ERR && c != '\n'); + ungetC('\n'); + goto ret; + } c = 0; h = 0; do { @@ -357,13 +364,6 @@ word(int parsehtime) default: break; } - if (intty && c == '#') { - Strbuf_append1(&wbuf, c); - while ((c = readc(1)) != CHAR_ERR && c != '\n') - Strbuf_append1(&wbuf, c); - unreadc('\n'); - goto ret; - } c1 = 0; dolflg = DOALL; for (;;) { diff --git a/sh.parse.c b/sh.parse.c index 314739af..721c54d9 100644 --- a/sh.parse.c +++ b/sh.parse.c @@ -197,6 +197,8 @@ freenod(struct wordent *p1, struct wordent *p2) #define P_OUT 4 #define P_DIAG 8 +char *pchrs; + /* * syntax * empty @@ -205,9 +207,8 @@ freenod(struct wordent *p1, struct wordent *p2) struct command * syntax(const struct wordent *p1, const struct wordent *p2, int flags) { - while (p1 != p2) - if (any(intty ? ";&\n#" : ";&\n", p1->word[0])) + if (any(pchrs, p1->word[0])) p1 = p1->next; else return (syn0(p1, p2, flags));