summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorjilles <jilles@FreeBSD.org>2013-04-01 20:50:07 +0000
committerjilles <jilles@FreeBSD.org>2013-04-01 20:50:07 +0000
commit8435d3c02c8802b5019ee98f13f0270b332106c5 (patch)
tree5cabe0e6eee561c3332e1206fccea783f53729b8 /tools
parent5d624f8f14afb145964ba64fad16cecd1bc094a0 (diff)
downloadFreeBSD-src-8435d3c02c8802b5019ee98f13f0270b332106c5.zip
FreeBSD-src-8435d3c02c8802b5019ee98f13f0270b332106c5.tar.gz
wordexp(): Remove wrong IFS usage.
Words in shell script are separated by spaces or tabs independent of the value of IFS. The value of IFS is only relevant for the result of substitutions. Therefore, there should be a space between 'wordexp' and the words to be expanded, not an IFS character. Paranoia might dictate that the shell ignore IFS from the environment (even though our sh currently uses it), so do not depend on it in the new test case.
Diffstat (limited to 'tools')
-rw-r--r--tools/regression/lib/libc/gen/test-wordexp.c19
1 files changed, 19 insertions, 0 deletions
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