From owner-svn-src-all@FreeBSD.ORG Wed Aug 17 13:56:33 2011 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D3808106566C; Wed, 17 Aug 2011 13:56:33 +0000 (UTC) (envelope-from gabor@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C328A8FC15; Wed, 17 Aug 2011 13:56:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.4/8.14.4) with ESMTP id p7HDuXEb007914; Wed, 17 Aug 2011 13:56:33 GMT (envelope-from gabor@svn.freebsd.org) Received: (from gabor@localhost) by svn.freebsd.org (8.14.4/8.14.4/Submit) id p7HDuXPm007912; Wed, 17 Aug 2011 13:56:33 GMT (envelope-from gabor@svn.freebsd.org) Message-Id: <201108171356.p7HDuXPm007912@svn.freebsd.org> From: Gabor Kovesdan Date: Wed, 17 Aug 2011 13:56:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r224937 - head/usr.bin/grep X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Aug 2011 13:56:33 -0000 Author: gabor Date: Wed Aug 17 13:56:33 2011 New Revision: 224937 URL: http://svn.freebsd.org/changeset/base/224937 Log: - Fix handling of environmental variables when they are set to empty string Submitted by: ttsestt@gmail.com Approved by: re (kib), delphij (mentor) Modified: head/usr.bin/grep/grep.c Modified: head/usr.bin/grep/grep.c ============================================================================== --- head/usr.bin/grep/grep.c Wed Aug 17 13:02:50 2011 (r224936) +++ head/usr.bin/grep/grep.c Wed Aug 17 13:56:33 2011 (r224937) @@ -304,7 +304,7 @@ init_color(const char *d) char *c; c = getenv("GREP_COLOR"); - return (c != NULL ? c : d); + return (c != NULL && c[0] != '\0' ? c : d); } int @@ -360,7 +360,7 @@ main(int argc, char *argv[]) /* support for extra arguments in GREP_OPTIONS */ eargc = 0; - if (eopts != NULL) { + if (eopts != NULL && eopts[0] != '\0') { char *str; /* make an estimation of how many extra arguments we have */ @@ -373,7 +373,8 @@ main(int argc, char *argv[]) eargc = 0; /* parse extra arguments */ while ((str = strsep(&eopts, " ")) != NULL) - eargv[eargc++] = grep_strdup(str); + if (str[0] != '\0') + eargv[eargc++] = grep_strdup(str); aargv = (char **)grep_calloc(eargc + argc + 1, sizeof(char *));