about summary refs log tree commit diff
path: root/posix/globtest.sh
diff options
context:
space:
mode:
authorUlrich Drepper <drepper@redhat.com>2007-02-14 19:52:38 +0000
committerUlrich Drepper <drepper@redhat.com>2007-02-14 19:52:38 +0000
commit05f135ba3b85e0bf2449df6a678f001453d975ce (patch)
tree5f531106f88278f165d2e58e7985ccf639775fc8 /posix/globtest.sh
parent2f69996772e39953951a3c5d8df885c775601060 (diff)
downloadglibc-05f135ba3b85e0bf2449df6a678f001453d975ce.tar.gz
glibc-05f135ba3b85e0bf2449df6a678f001453d975ce.tar.xz
glibc-05f135ba3b85e0bf2449df6a678f001453d975ce.zip
[BZ #3996]
2007-02-14  Jakub Jelinek  <jakub@redhat.com>
	[BZ #3996]
	* posix/glob.c (attribute_hidden): Define if not defined.
	(glob): Unescape dirname, filename or username when needed and not
	GLOB_NOESCAPE.  Handle \/ correctly.  Handle GLOB_MARK if filename
	is NULL.  Handle unescaped [ in pattern without closing ].
	Don't pass GLOB_CHECK down to recursive glob for directories.
	(__glob_pattern_type): New function.
	(__glob_pattern_p): Implement using __glob_pattern_type.
	(glob_in_dir): Handle GLOB_NOCHECK patterns containing no meta
	characters and backslashes if not GLOB_NOESCAPE or unterminated [.
	Remove unreachable code.
	* posix/globtest.sh: Add a couple of new tests.
Diffstat (limited to 'posix/globtest.sh')
-rwxr-xr-xposix/globtest.sh71
1 files changed, 71 insertions, 0 deletions
diff --git a/posix/globtest.sh b/posix/globtest.sh
index 09af6f74f5..ad47508a66 100755
--- a/posix/globtest.sh
+++ b/posix/globtest.sh
@@ -706,6 +706,77 @@ if test $failed -ne 0; then
   result=1
 fi
 
+mkdir $testdir/'dir3*'
+echo 1 > $testdir/'dir3*'/file1
+mkdir $testdir/'dir4[a'
+echo 2 > $testdir/'dir4[a'/file1
+echo 3 > $testdir/'dir4[a'/file2
+mkdir $testdir/'dir5[ab]'
+echo 4 > $testdir/'dir5[ab]'/file1
+echo 5 > $testdir/'dir5[ab]'/file2
+mkdir $testdir/dir6
+echo 6 > $testdir/dir6/'file1[a'
+echo 7 > $testdir/dir6/'file1[ab]'
+failed=0
+v=`${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+   ${common_objpfx}posix/globtest "$testdir" 'dir3\*/file2'`
+test "$v" != 'GLOB_NOMATCH' && echo "$v" >> $logfile && failed=1
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -c "$testdir" \
+'dir3\*/file1' 'dir3\*/file2' 'dir1/file\1_1' 'dir1/file\1_9' \
+'dir2\/' 'nondir\/' 'dir4[a/fil*1' 'di*r4[a/file2' 'dir5[ab]/file[12]' \
+'dir6/fil*[a' 'dir*6/file1[a' 'dir6/fi*l[ab]' 'dir*6/file1[ab]' |
+sort > $testout
+cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
+`di*r4[a/file2'
+`dir*6/file1[a'
+`dir*6/file1[ab]'
+`dir1/file1_1'
+`dir1/file\1_9'
+`dir2/'
+`dir3*/file1'
+`dir3\*/file2'
+`dir4[a/fil*1'
+`dir5[ab]/file[12]'
+`dir6/fi*l[ab]'
+`dir6/fil*[a'
+`nondir\/'
+EOF
+HOME="$testdir" \
+${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+${common_objpfx}posix/globtest -ct "$testdir" \
+'~/dir1/file1_1' '~/dir1/file1_9' '~/dir3\*/file1' '~/dir3\*/file2' \
+'~\/dir1/file1_2' |
+sort > $testout
+cat <<EOF | $CMP - $testout >> $logfile || failed=1
+\`$testdir/dir1/file1_1'
+\`$testdir/dir1/file1_2'
+\`$testdir/dir3*/file1'
+\`~/dir1/file1_9'
+\`~/dir3\\*/file2'
+EOF
+if eval test -d ~"$USER"/; then
+  user=`echo "$USER" | sed -n -e 's/^\([^\\]\)\([^\\][^\\]*\)$/~\1\\\\\2/p'`
+  if test -n "$user"; then
+    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${common_objpfx}posix/globtest -ctq "$testdir" "$user/" |
+    sort > $testout
+    eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1
+    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${common_objpfx}posix/globtest -ctq "$testdir" "$user\\/" |
+    sort > $testout
+    eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1
+    ${elf_objpfx}${rtld_installed_name} --library-path ${library_path} \
+    ${common_objpfx}posix/globtest -ctq "$testdir" "$user" |
+    sort > $testout
+    eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
+  fi
+fi
+if test $failed -ne 0; then
+  echo "Escape tests failed" >> $logfile
+  result=1
+fi
+
 if test $result -eq 0; then
     chmod 777 $testdir/noread
     rm -fr $testdir $testout