From: Trent Huber Date: Thu, 4 Sep 2025 23:05:41 +0000 (-0400) Subject: Fix pipes X-Git-Url: https://trenthuber.com/code?a=commitdiff_plain;h=f3b04343b6176f5a7e6d74320616831a99e695b5;p=thus.git Fix pipes --- diff --git a/src/parse.c b/src/parse.c index b81a33e..bda7ae1 100644 --- a/src/parse.c +++ b/src/parse.c @@ -20,14 +20,15 @@ int parse(struct context *c) { if (!c->input(c)) return 0; c->b = c->buffer; } - if (globs.gl_pathc) { - globfree(&globs); - globs.gl_pathc = 0; - } c->t = c->tokens; c->r = c->redirects; c->r->mode = NONE; c->prev = c->current; + + if (globs.gl_pathc) { + globfree(&globs); + globs.gl_pathc = 0; + } prevsublen = globbing = 0; for (*c->t = c->b; *c->b; ++c->b) switch (*c->b) { diff --git a/src/run.c b/src/run.c index 105c0f8..375bf1f 100644 --- a/src/run.c +++ b/src/run.c @@ -74,6 +74,7 @@ int run(struct context *c) { setsigchld(&actbg); if (!parse(c)) return 0; setsigchld(&actdefault); + islist = c->prev.term > BG || c->current.term > BG; if (c->t) { if (c->current.term == BG && fullbg()) { @@ -82,9 +83,7 @@ int run(struct context *c) { } if (!(path = getpath(c->current.name))) { note("Couldn't find `%s' command", c->current.name); - if (c->prev.term == PIPE) { - killpg(pipeid, SIGKILL); - } + if (c->prev.term == PIPE) killpg(pipeid, SIGKILL); return quit(c); } @@ -114,7 +113,7 @@ int run(struct context *c) { } exec(path, c); } - if (ispipestart) pipeid = cpid; + if (ispipestart) pipeid = cpid; else closepipe(c->prev); jobid = pipeid; } else if (!c->r && isbuiltin(c->tokens)) cpid = 0; else if ((jobid = cpid = fork()) == -1) {