about summary refs log tree commit diff
path: root/posix
diff options
context:
space:
mode:
Diffstat (limited to 'posix')
-rw-r--r--posix/globtest.c7
-rwxr-xr-xposix/globtest.sh29
2 files changed, 20 insertions, 16 deletions
diff --git a/posix/globtest.c b/posix/globtest.c
index 589e91b973..7008a8bcd1 100644
--- a/posix/globtest.c
+++ b/posix/globtest.c
@@ -18,6 +18,7 @@
 
 #include <stdio.h>
 #include <glob.h>
+#include <unistd.h>
 
 int
 main (int argc, char *argv[])
@@ -26,7 +27,11 @@ main (int argc, char *argv[])
   int glob_flags = GLOB_NOSORT;
   glob_t filenames;
 
-  i = glob (argv[1], glob_flags, NULL, &filenames);
+  if (argc != 3)
+    exit (1);
+  if (chdir (argv[1]))
+    exit (1);
+  i = glob (argv[2], glob_flags, NULL, &filenames);
 
   if (i == GLOB_NOSPACE)
     puts ("GLOB_NOSPACE");
diff --git a/posix/globtest.sh b/posix/globtest.sh
index c51655b9b3..61fec9874c 100755
--- a/posix/globtest.sh
+++ b/posix/globtest.sh
@@ -20,10 +20,9 @@ echo 1_2 > $testdir/dir1/file1_2
 
 # Run some tests.
 result=0
-here=`pwd`
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 `dir1'
@@ -33,8 +32,8 @@ cat <<"EOF" | cmp - $testout || result=1
 not NULL
 EOF
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/*") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*/*" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 `dir1/file1_1'
@@ -42,40 +41,40 @@ cat <<"EOF" | cmp - $testout || result=1
 not NULL
 EOF
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/1") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*/1" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 GLOB_NOMATCH
 NULL
 EOF
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/*1_1") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 `dir1/file1_1'
 not NULL
 EOF
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*/file1_1") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 `dir1/file1_1'
 not NULL
 EOF
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*-/*") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*-/*" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 GLOB_NOMATCH
 NULL
 EOF
 
-(cd $testdir &&
- LD_LIBRARY_PATH=$common_objpfx $common_objpfx/posix/globtest "*-") |
+LD_LIBRARY_PATH=$common_objpfx \
+${common_objpfx}posix/globtest "$testdir" "*-" |
 sort > $testout
 cat <<"EOF" | cmp - $testout || result=1
 GLOB_NOMATCH