svn commit: r307638 - head/usr.bin/printenv
Pietro Cerutti
gahr at FreeBSD.org
Wed Oct 19 14:51:26 UTC 2016
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);
}
}
More information about the svn-src-all
mailing list