From owner-svn-src-head@freebsd.org Wed Oct 19 14:51:26 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 46D7FC18D18; Wed, 19 Oct 2016 14:51:26 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 18F99C2A; Wed, 19 Oct 2016 14:51:26 +0000 (UTC) (envelope-from gahr@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u9JEpPKW097479; Wed, 19 Oct 2016 14:51:25 GMT (envelope-from gahr@FreeBSD.org) Received: (from gahr@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u9JEpP3v097478; Wed, 19 Oct 2016 14:51:25 GMT (envelope-from gahr@FreeBSD.org) Message-Id: <201610191451.u9JEpP3v097478@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: gahr set sender to gahr@FreeBSD.org using -f From: Pietro Cerutti Date: Wed, 19 Oct 2016 14:51:25 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r307638 - head/usr.bin/printenv X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Oct 2016 14:51:26 -0000 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); } }