From 3652bc8e09d2a229bacc913b85ebbc7cbc866545 Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Wed, 19 Oct 2016 14:51:25 +0000 Subject: [PATCH] Chase a cornercase in printenv and sync its behaviour with builtin's The cornercase is when printenv is passed a parameter in the form VAR=val, where VAR=val exists in the environment. In this case, printenv would print a spurious newline and returns 0. Approved by: cognet MFC after: 1 week --- usr.bin/printenv/printenv.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/usr.bin/printenv/printenv.c b/usr.bin/printenv/printenv.c index 315833e85a75..27882ab91ce3 100644 --- a/usr.bin/printenv/printenv.c +++ b/usr.bin/printenv/printenv.c @@ -83,8 +83,8 @@ main(int argc, char *argv[]) for (ep = environ; *ep; ep++) if (!memcmp(*ep, *argv, len)) { cp = *ep + len; - if (!*cp || *cp == '=') { - (void)printf("%s\n", *cp ? cp + 1 : cp); + if (*cp == '=') { + (void)printf("%s\n", cp + 1); exit(0); } }