From f3b04343b6176f5a7e6d74320616831a99e695b5 Mon Sep 17 00:00:00 2001 From: Trent Huber Date: Thu, 4 Sep 2025 19:05:41 -0400 Subject: [PATCH] Fix pipes --- src/parse.c | 9 +++++---- src/run.c | 7 +++---- 2 files changed, 8 insertions(+), 8 deletions(-) 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) { -- 2.51.0