From owner-svn-src-all@FreeBSD.ORG Thu May 9 11:43:46 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.FreeBSD.org [8.8.178.115]) by hub.freebsd.org (Postfix) with ESMTP id 304B35AE; Thu, 9 May 2013 11:43:46 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 2284112E; Thu, 9 May 2013 11:43:46 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.6/8.14.6) with ESMTP id r49BhkDF042064; Thu, 9 May 2013 11:43:46 GMT (envelope-from jilles@svn.freebsd.org) Received: (from jilles@localhost) by svn.freebsd.org (8.14.6/8.14.5/Submit) id r49Bhk4L042063; Thu, 9 May 2013 11:43:46 GMT (envelope-from jilles@svn.freebsd.org) Message-Id: <201305091143.r49Bhk4L042063@svn.freebsd.org> From: Jilles Tjoelker Date: Thu, 9 May 2013 11:43:45 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r250406 - head/lib/libc/gen X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 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: Thu, 09 May 2013 11:43:46 -0000 Author: jilles Date: Thu May 9 11:43:45 2013 New Revision: 250406 URL: http://svnweb.freebsd.org/changeset/base/250406 Log: wordexp(): Simplify code by deferring work to sh. Modified: head/lib/libc/gen/wordexp.c Modified: head/lib/libc/gen/wordexp.c ============================================================================== --- head/lib/libc/gen/wordexp.c Thu May 9 11:10:46 2013 (r250405) +++ head/lib/libc/gen/wordexp.c Thu May 9 11:43:45 2013 (r250406) @@ -139,25 +139,15 @@ we_askshell(const char *words, wordexp_t * We are the child; just get /bin/sh to run the wordexp * builtin on `words'. */ - int devnull; - char *cmd; - (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); _close(pdes[0]); if (_dup2(pdes[1], STDOUT_FILENO) < 0) _exit(1); _close(pdes[1]); - if (asprintf(&cmd, "wordexp %s\n", words) < 0) - _exit(1); - if ((flags & WRDE_SHOWERR) == 0) { - if ((devnull = _open(_PATH_DEVNULL, O_RDWR, 0666)) < 0) - _exit(1); - if (_dup2(devnull, STDERR_FILENO) < 0) - _exit(1); - _close(devnull); - } execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u", - "-c", cmd, (char *)NULL); + "-c", "eval \"$1\";eval \"wordexp $2\"", "", + flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words, + (char *)NULL); _exit(1); }