Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion sh.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))) {
Expand Down
1 change: 1 addition & 0 deletions sh.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
12 changes: 9 additions & 3 deletions sh.lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,7 @@ lex(struct wordent *hp)
int parsehtime = enterhist;
int toolong = 0;

histvalid = 0;
histline.len = 0;
histvalid = histline.len = 0;

if (!postcmd_active)
btell(&lineloc);
Expand Down Expand Up @@ -320,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 {
Expand Down
17 changes: 15 additions & 2 deletions sh.parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ freenod(struct wordent *p1, struct wordent *p2)
#define P_OUT 4
#define P_DIAG 8

char *pchrs;

/*
* syntax
* empty
Expand All @@ -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(";&\n", p1->word[0]))
if (any(pchrs, p1->word[0]))
p1 = p1->next;
else
return (syn0(p1, p2, flags));
Expand Down Expand Up @@ -273,9 +274,21 @@ syn0(const struct wordent *p1, const struct wordent *p2, int flags)
t->t_dcar = t1;
t->t_dcdr = syntax(p, p2, flags);
return (t);

case '#':
if (intty) {
struct wordent *p1 = p2->prev;

p1 = p1->prev = p1->prev->prev;
xfree(p1->next->word);
xfree(p1->next);
p1->next = p2->prev;
goto out;
}
default:
break;
}
out:
if (l == 0)
return (syn1(p1, p2, flags));
seterror(ERR_TOOMANYLP);
Expand Down