aboutsummaryrefslogtreecommitdiff
path: root/lib/libc/gen/wordexp.c
diff options
context:
space:
mode:
authorJilles Tjoelker <jilles@FreeBSD.org>2013-05-09 11:43:45 +0000
committerJilles Tjoelker <jilles@FreeBSD.org>2013-05-09 11:43:45 +0000
commitae4c676c55685194110a9dcdc4d37615fb167555 (patch)
tree73f946557fd0b889527b4ffe34692aaa705d62d5 /lib/libc/gen/wordexp.c
parent198ee3001d52ce532e13801f1cd144f9ea62d185 (diff)
downloadsrc-ae4c676c55685194110a9dcdc4d37615fb167555.tar.gz
src-ae4c676c55685194110a9dcdc4d37615fb167555.zip
Notes
Diffstat (limited to 'lib/libc/gen/wordexp.c')
-rw-r--r--lib/libc/gen/wordexp.c16
1 files changed, 3 insertions, 13 deletions
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index b518b57ae5ea..7d8b8f9044ee 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -139,25 +139,15 @@ we_askshell(const char *words, wordexp_t *we, int flags)
* 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);
}