Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 19 Oct 2016 14:51:25 +0000 (UTC)
From:      Pietro Cerutti <gahr@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r307638 - head/usr.bin/printenv
Message-ID:  <201610191451.u9JEpP3v097478@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: gahr (ports committer)
Date: Wed Oct 19 14:51:25 2016
New Revision: 307638
URL: https://svnweb.freebsd.org/changeset/base/307638

Log:
  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

Modified:
  head/usr.bin/printenv/printenv.c

Modified: head/usr.bin/printenv/printenv.c
==============================================================================
--- head/usr.bin/printenv/printenv.c	Wed Oct 19 14:28:51 2016	(r307637)
+++ head/usr.bin/printenv/printenv.c	Wed Oct 19 14:51:25 2016	(r307638)
@@ -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);
 			}
 		}



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201610191451.u9JEpP3v097478>