From 38cc01b8874900eab684d70847b8ca3a3e580a0f Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Fri, 20 Oct 2017 22:26:30 -0700 Subject: [PATCH] which: Minor simplification --- which.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/which.c b/which.c index 1e64452..cc93361 100644 --- a/which.c +++ b/which.c @@ -50,12 +50,10 @@ which(const char *path, const char *name) if (i && ptr[i - 1] != '/') fputc('/', stdout); puts(name); - if (!aflag) { - close(dirfd); - break; - } } close(dirfd); + if (!aflag && found) + break; } p = ptr + i + 1; }