summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/libc/gen/wordexp.c5
-rw-r--r--tools/regression/lib/libc/gen/test-wordexp.c19
2 files changed, 20 insertions, 4 deletions
diff --git a/lib/libc/gen/wordexp.c b/lib/libc/gen/wordexp.c
index bcab1f5..b518b57 100644
--- a/lib/libc/gen/wordexp.c
+++ b/lib/libc/gen/wordexp.c
@@ -114,15 +114,12 @@ we_askshell(const char *words, wordexp_t *we, int flags)
int status; /* Child exit status */
int error; /* Our return value */
int serrno; /* errno to return */
- char *ifs; /* IFS env. var. */
char *np, *p; /* Handy pointers */
char *nstrings; /* Temporary for realloc() */
char **nwv; /* Temporary for realloc() */
sigset_t newsigblock, oldsigblock;
serrno = errno;
- if ((ifs = getenv("IFS")) == NULL)
- ifs = " \t\n";
if (pipe(pdes) < 0)
return (WRDE_NOSPACE); /* XXX */
@@ -150,7 +147,7 @@ we_askshell(const char *words, wordexp_t *we, int flags)
if (_dup2(pdes[1], STDOUT_FILENO) < 0)
_exit(1);
_close(pdes[1]);
- if (asprintf(&cmd, "wordexp%c%s\n", *ifs, words) < 0)
+ if (asprintf(&cmd, "wordexp %s\n", words) < 0)
_exit(1);
if ((flags & WRDE_SHOWERR) == 0) {
if ((devnull = _open(_PATH_DEVNULL, O_RDWR, 0666)) < 0)
diff --git a/tools/regression/lib/libc/gen/test-wordexp.c b/tools/regression/lib/libc/gen/test-wordexp.c
index df8f885..d94f870 100644
--- a/tools/regression/lib/libc/gen/test-wordexp.c
+++ b/tools/regression/lib/libc/gen/test-wordexp.c
@@ -208,6 +208,25 @@ main(int argc, char *argv[])
assert(strcmp(we.we_wordv[1], "world") == 0);
assert(we.we_wordv[2] == NULL);
wordfree(&we);
+ sa.sa_handler = SIG_DFL;
+ r = sigaction(SIGCHLD, &sa, NULL);
+ assert(r == 0);
+
+ /*
+ * With IFS set to a non-default value (without depending on whether
+ * IFS is inherited or not).
+ */
+ r = setenv("IFS", ":", 1);
+ assert(r == 0);
+ r = wordexp("hello world", &we, 0);
+ assert(r == 0);
+ assert(we.we_wordc == 2);
+ assert(strcmp(we.we_wordv[0], "hello") == 0);
+ assert(strcmp(we.we_wordv[1], "world") == 0);
+ assert(we.we_wordv[2] == NULL);
+ wordfree(&we);
+ r = unsetenv("IFS");
+ assert(r == 0);
printf("PASS wordexp()\n");
printf("PASS wordfree()\n");
OpenPOWER on IntegriCloud