From owner-svn-src-head@freebsd.org Sun Aug 16 19:42:16 2015 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 0A1759BB7A8; Sun, 16 Aug 2015 19:42:16 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::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 ED71018AA; Sun, 16 Aug 2015 19:42:15 +0000 (UTC) (envelope-from jilles@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t7GJgFjr032643; Sun, 16 Aug 2015 19:42:15 GMT (envelope-from jilles@FreeBSD.org) Received: (from jilles@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t7GJgFPs032642; Sun, 16 Aug 2015 19:42:15 GMT (envelope-from jilles@FreeBSD.org) Message-Id: <201508161942.t7GJgFPs032642@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: jilles set sender to jilles@FreeBSD.org using -f From: Jilles Tjoelker Date: Sun, 16 Aug 2015 19:42:15 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r286830 - 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-head@freebsd.org X-Mailman-Version: 2.1.20 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: Sun, 16 Aug 2015 19:42:16 -0000 Author: jilles Date: Sun Aug 16 19:42:15 2015 New Revision: 286830 URL: https://svnweb.freebsd.org/changeset/base/286830 Log: wordexp(): Stop using the undocumented wordexp builtin. The functionality of the wordexp builtin is easily replaced using normal shell code, although performance is slightly worse. This does not mean that wordexp() will remain shell-independent -- a fully reliable implementation of WRDE_NOCMD is really only possible using extensions to the shell, or by adding much of the shell's code to libc. Modified: head/lib/libc/gen/wordexp.c Modified: head/lib/libc/gen/wordexp.c ============================================================================== --- head/lib/libc/gen/wordexp.c Sun Aug 16 19:06:23 2015 (r286829) +++ head/lib/libc/gen/wordexp.c Sun Aug 16 19:42:15 2015 (r286830) @@ -138,8 +138,7 @@ we_askshell(const char *words, wordexp_t } else if (pid == 0) { /* - * We are the child; just get /bin/sh to run the wordexp - * builtin on `words'. + * We are the child; make /bin/sh expand `words'. */ (void)_sigprocmask(SIG_SETMASK, &oldsigblock, NULL); if ((pdes[1] != STDOUT_FILENO ? @@ -147,7 +146,9 @@ we_askshell(const char *words, wordexp_t _fcntl(pdes[1], F_SETFD, 0)) < 0) _exit(1); execl(_PATH_BSHELL, "sh", flags & WRDE_UNDEF ? "-u" : "+u", - "-c", "IFS=$1;eval \"$2\";eval \"wordexp $3\"", "", + "-c", "IFS=$1;eval \"$2\";eval \"set -- $3\";IFS=;a=\"$*\";" + "printf '%08x' \"$#\" \"${#a}\";printf '%s\\0' \"$@\"", + "", ifs != NULL ? ifs : " \t\n", flags & WRDE_SHOWERR ? "" : "exec 2>/dev/null", words, (char *)NULL);