about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/Makefile11
-rw-r--r--posix/wordexp-test.c2
-rwxr-xr-xposix/wordexp-tst.sh24
-rw-r--r--posix/wordexp.c6
4 files changed, 35 insertions, 8 deletions
diff --git a/posix/Makefile b/posix/Makefile
index 0fc1787968..7b00d48435 100644
--- a/posix/Makefile
+++ b/posix/Makefile
@@ -64,9 +64,14 @@ before-compile	:= testcases.h
 include ../Rules
 
 ifeq (no,$(cross-compiling))
-tests: $(objpfx)globtest $(objpfx)wordexp-test
-	$(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) $(rtld-installed-name)
-	$(SHELL) -e wordexp-tst.sh $(common-objpfx) $(elf-objpfx) $(rtld-installed-name)
+.PHONY: do-globtest do-wordexp-tst
+tests: do-globtest do-wordexp-test
+do-globtest: $(objpfx)globtest
+	$(SHELL) -e globtest.sh $(common-objpfx) $(elf-objpfx) \
+		 $(rtld-installed-name)
+do-wordexp-test: $(objpfx)wordexp-test
+	$(SHELL) -e wordexp-tst.sh $(common-objpfx) $(elf-objpfx) \
+		 $(rtld-installed-name)
 endif
 
 CFLAGS-regex.c = -Wno-unused -Wno-strict-prototypes
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index 2fc5f0ffac..1797a7a42e 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -164,7 +164,7 @@ main (int argc, char *argv[])
   const char *globfile[] = { "one", "two", "three", NULL };
   char tmpdir[32];
   struct passwd *pw;
-  char *cwd;
+  const char *cwd;
   int test;
   int fail = 0;
   int i;
diff --git a/posix/wordexp-tst.sh b/posix/wordexp-tst.sh
index e1f0b78830..57ef01383b 100755
--- a/posix/wordexp-tst.sh
+++ b/posix/wordexp-tst.sh
@@ -12,7 +12,13 @@ rtld_installed_name=$1; shift
 testout=$TMPDIR/wordexp-test-result
 
 failed=0
-export IFS=$(echo -e " \t\n")
+# This is written in this funny way so that there is no trailing whitespace.
+# The first line contains a space followed by a tab.
+IFS=" 	\
+
+"
+export IFS
+
 
 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
@@ -70,4 +76,20 @@ we_wordv[2] = "4"
 we_wordv[3] = "th"
 EOF
 
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
+cat <<"EOF" | cmp - ${testout}8 || failed=1
+wordexp returned 0
+we_wordv[0] = "11"
+EOF
+
+${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
+${common_objpfx}posix/wordexp-test '"a $@ b"' c d > ${testout}9
+cat <<"EOF" | cmp - ${testout}9 || failed=1
+wordexp returned 0
+we_wordv[0] = "a "a $@ b""
+we_wordv[1] = "c"
+we_wordv[2] = "d b"
+EOF
+
 exit $failed
diff --git a/posix/wordexp.c b/posix/wordexp.c
index 1c69af8a1c..268a0e8c86 100644
--- a/posix/wordexp.c
+++ b/posix/wordexp.c
@@ -1548,7 +1548,7 @@ envsubst:
 		pattern = qtd_pattern;
 	      }
 
-	    if (pattern == NULL && (pattern = __strdup("")) == NULL)
+	    if (pattern == NULL && (pattern = __strdup ("")) == NULL)
 	      goto no_space;
 
 	    error = wordexp (pattern, &we, flags);
@@ -1563,8 +1563,8 @@ envsubst:
 	    assert (!quoted || we.we_wordc == 1);
 
 	    /* Substitute */
-	    for (i = 0; i < we.we_wordc; i++)
-	      if (w_addword (pwordexp, __strdup(we.we_wordv[i]))
+	    for (i = 0; i < we.we_wordc; ++i)
+	      if (w_addword (pwordexp, __strdup (we.we_wordv[i]))
 		  == WRDE_NOSPACE)
 		break;