1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-11-25 07:49:18 +00:00

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
This commit is contained in:
Pietro Cerutti 2016-10-19 14:51:25 +00:00
parent 99746e4658
commit 3652bc8e09
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=307638

View File

@ -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);
}
}