Update copyright notices with scripts/update-copyrights
[glibc.git] / posix / globtest.sh
blobd76fc6c772e8cd44e36b760fb61dcd7d45b9294a
1 #! /bin/bash
2 # Test for glob(3).
3 # Copyright (C) 1997-2014 Free Software Foundation, Inc.
4 # This file is part of the GNU C Library.
6 # The GNU C Library is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU Lesser General Public
8 # License as published by the Free Software Foundation; either
9 # version 2.1 of the License, or (at your option) any later version.
11 # The GNU C Library is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 # Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public
17 # License along with the GNU C Library; if not, see
18 # <http://www.gnu.org/licenses/>.
20 set -e
22 common_objpfx=$1; shift
23 test_via_rtld_prefix=$1; shift
24 test_program_prefix=$1; shift
25 test_wrapper_env=$1; shift
26 logfile=$common_objpfx/posix/globtest.out
28 #CMP=cmp
29 CMP="diff -u"
31 # We have to make the paths `common_objpfx' absolute.
32 case "$common_objpfx" in
33 .*)
34 common_objpfx="`pwd`/$common_objpfx"
38 esac
40 # Since we use `sort' we must make sure to use the same locale everywhere.
41 LC_ALL=C
42 export LC_ALL
43 LANG=C
44 export LANG
46 # Create the arena
47 testdir=${common_objpfx}posix/globtest-dir
48 testout=${common_objpfx}posix/globtest-out
49 rm -rf $testdir $testout
50 mkdir $testdir
52 trap 'chmod 777 $testdir/noread; rm -fr $testdir $testout' 1 2 3 15
54 echo 1 > $testdir/file1
55 echo 2 > $testdir/file2
56 echo 3 > $testdir/-file3
57 echo 4 > $testdir/~file4
58 echo 5 > $testdir/.file5
59 echo 6 > $testdir/'*file6'
60 echo 7 > $testdir/'{file7,}'
61 echo 8 > $testdir/'\{file8\}'
62 echo 9 > $testdir/'\{file9\,file9b\}'
63 echo 9 > $testdir/'\file9b\' #'
64 echo a > $testdir/'filea,'
65 echo a > $testdir/'fileb}c'
66 mkdir $testdir/dir1
67 mkdir $testdir/dir2
68 test -d $testdir/noread || mkdir $testdir/noread
69 chmod a-r $testdir/noread
70 echo 1_1 > $testdir/dir1/file1_1
71 echo 1_2 > $testdir/dir1/file1_2
72 ln -fs dir1 $testdir/link1
74 # Run some tests.
75 result=0
76 rm -f $logfile
78 # Normal test
79 failed=0
80 ${test_program_prefix} \
81 ${common_objpfx}posix/globtest "$testdir" "*" |
82 sort > $testout
83 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
84 `*file6'
85 `-file3'
86 `\file9b\'
87 `\{file8\}'
88 `\{file9\,file9b\}'
89 `dir1'
90 `dir2'
91 `file1'
92 `file2'
93 `filea,'
94 `fileb}c'
95 `link1'
96 `noread'
97 `{file7,}'
98 `~file4'
99 EOF
100 if test $failed -ne 0; then
101 echo "Normal test failed" >> $logfile
102 result=1
105 # Don't let glob sort it
106 failed=0
107 ${test_program_prefix} \
108 ${common_objpfx}posix/globtest -s "$testdir" "*" |
109 sort > $testout
110 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
111 `*file6'
112 `-file3'
113 `\file9b\'
114 `\{file8\}'
115 `\{file9\,file9b\}'
116 `dir1'
117 `dir2'
118 `file1'
119 `file2'
120 `filea,'
121 `fileb}c'
122 `link1'
123 `noread'
124 `{file7,}'
125 `~file4'
127 if test $failed -ne 0; then
128 echo "No sort test failed" >> $logfile
129 result=1
132 # Mark directories
133 failed=0
134 ${test_program_prefix} \
135 ${common_objpfx}posix/globtest -m "$testdir" "*" |
136 sort > $testout
137 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
138 `*file6'
139 `-file3'
140 `\file9b\'
141 `\{file8\}'
142 `\{file9\,file9b\}'
143 `dir1/'
144 `dir2/'
145 `file1'
146 `file2'
147 `filea,'
148 `fileb}c'
149 `link1/'
150 `noread/'
151 `{file7,}'
152 `~file4'
154 if test $failed -ne 0; then
155 echo "Mark directories test failed" >> $logfile
156 result=1
159 # Find files starting with .
160 failed=0
161 ${test_program_prefix} \
162 ${common_objpfx}posix/globtest -p "$testdir" "*" |
163 sort > $testout
164 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
165 `*file6'
166 `-file3'
168 `..'
169 `.file5'
170 `\file9b\'
171 `\{file8\}'
172 `\{file9\,file9b\}'
173 `dir1'
174 `dir2'
175 `file1'
176 `file2'
177 `filea,'
178 `fileb}c'
179 `link1'
180 `noread'
181 `{file7,}'
182 `~file4'
184 if test $failed -ne 0; then
185 echo "Leading period test failed" >> $logfile
186 result=1
189 # Test braces
190 failed=0
191 ${test_program_prefix} \
192 ${common_objpfx}posix/globtest -b "$testdir" "file{1,2}" |
193 sort > $testout
194 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
195 `file1'
196 `file2'
198 if test $failed -ne 0; then
199 echo "Braces test failed" >> $logfile
200 result=1
203 failed=0
204 ${test_program_prefix} \
205 ${common_objpfx}posix/globtest -b "$testdir" "{file{1,2},-file3}" |
206 sort > $testout
207 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
208 `-file3'
209 `file1'
210 `file2'
212 if test $failed -ne 0; then
213 echo "Braces test 2 failed" >> $logfile
214 result=1
217 failed=0
218 ${test_program_prefix} \
219 ${common_objpfx}posix/globtest -b "$testdir" "{" |
220 sort > $testout
221 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
222 GLOB_NOMATCH
224 if test $failed -ne 0; then
225 echo "Braces test 3 failed" >> $logfile
226 result=1
229 # Test NOCHECK
230 failed=0
231 ${test_program_prefix} \
232 ${common_objpfx}posix/globtest -c "$testdir" "abc" |
233 sort > $testout
234 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
235 `abc'
237 if test $failed -ne 0; then
238 echo "No check test failed" >> $logfile
239 result=1
242 # Test NOMAGIC without magic characters
243 failed=0
244 ${test_program_prefix} \
245 ${common_objpfx}posix/globtest -g "$testdir" "abc" |
246 sort > $testout
247 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
248 `abc'
250 if test $failed -ne 0; then
251 echo "No magic test failed" >> $logfile
252 result=1
255 # Test NOMAGIC with magic characters
256 failed=0
257 ${test_program_prefix} \
258 ${common_objpfx}posix/globtest -g "$testdir" "abc*" |
259 sort > $testout
260 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
261 GLOB_NOMATCH
263 if test $failed -ne 0; then
264 echo "No magic w/ magic chars test failed" >> $logfile
265 result=1
268 # Test NOMAGIC for subdirs
269 failed=0
270 ${test_program_prefix} \
271 ${common_objpfx}posix/globtest -g "$testdir" "*/does-not-exist" |
272 sort > $testout
273 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
274 GLOB_NOMATCH
276 if test $failed -ne 0; then
277 echo "No magic in subdir test failed" >> $logfile
278 result=1
281 # Test subdirs correctly
282 failed=0
283 ${test_program_prefix} \
284 ${common_objpfx}posix/globtest "$testdir" "*/*" |
285 sort > $testout
286 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
287 `dir1/file1_1'
288 `dir1/file1_2'
289 `link1/file1_1'
290 `link1/file1_2'
292 if test $failed -ne 0; then
293 echo "Subdirs test failed" >> $logfile
294 result=1
297 # Test subdirs for invalid names
298 failed=0
299 ${test_program_prefix} \
300 ${common_objpfx}posix/globtest "$testdir" "*/1" |
301 sort > $testout
302 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
303 GLOB_NOMATCH
305 if test $failed -ne 0; then
306 echo "Invalid subdir test failed" >> $logfile
307 result=1
310 # Test subdirs with wildcard
311 failed=0
312 ${test_program_prefix} \
313 ${common_objpfx}posix/globtest "$testdir" "*/*1_1" |
314 sort > $testout
315 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
316 `dir1/file1_1'
317 `link1/file1_1'
319 if test $failed -ne 0; then
320 echo "Wildcard subdir test failed" >> $logfile
321 result=1
324 # Test subdirs with ?
325 failed=0
326 ${test_program_prefix} \
327 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
328 sort > $testout
329 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
330 `dir1/file1_1'
331 `dir1/file1_2'
332 `link1/file1_1'
333 `link1/file1_2'
335 if test $failed -ne 0; then
336 echo "Wildcard2 subdir test failed" >> $logfile
337 result=1
340 failed=0
341 ${test_program_prefix} \
342 ${common_objpfx}posix/globtest "$testdir" "*/file1_1" |
343 sort > $testout
344 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
345 `dir1/file1_1'
346 `link1/file1_1'
348 if test $failed -ne 0; then
349 echo "Wildcard3 subdir test failed" >> $logfile
350 result=1
353 failed=0
354 ${test_program_prefix} \
355 ${common_objpfx}posix/globtest "$testdir" "*-/*" |
356 sort > $testout
357 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
358 GLOB_NOMATCH
360 if test $failed -ne 0; then
361 echo "Wildcard4 subdir test failed" >> $logfile
362 result=1
365 failed=0
366 ${test_program_prefix} \
367 ${common_objpfx}posix/globtest "$testdir" "*-" |
368 sort > $testout
369 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
370 GLOB_NOMATCH
372 if test $failed -ne 0; then
373 echo "Wildcard5 subdir test failed" >> $logfile
374 result=1
377 # Test subdirs with ?
378 failed=0
379 ${test_program_prefix} \
380 ${common_objpfx}posix/globtest "$testdir" "*/*?_?" |
381 sort > $testout
382 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
383 `dir1/file1_1'
384 `dir1/file1_2'
385 `link1/file1_1'
386 `link1/file1_2'
388 if test $failed -ne 0; then
389 echo "Wildcard6 subdir test failed" >> $logfile
390 result=1
393 # Test subdirs with [ .. ]
394 failed=0
395 ${test_program_prefix} \
396 ${common_objpfx}posix/globtest "$testdir" "*/file1_[12]" |
397 sort > $testout
398 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
399 `dir1/file1_1'
400 `dir1/file1_2'
401 `link1/file1_1'
402 `link1/file1_2'
404 if test $failed -ne 0; then
405 echo "Brackets test failed" >> $logfile
406 result=1
409 # Test ']' inside bracket expression
410 failed=0
411 ${test_program_prefix} \
412 ${common_objpfx}posix/globtest "$testdir" "dir1/file1_[]12]" |
413 sort > $testout
414 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
415 `dir1/file1_1'
416 `dir1/file1_2'
418 if test $failed -ne 0; then
419 echo "Brackets2 test failed" >> $logfile
420 result=1
423 # Test tilde expansion
424 failed=0
425 ${test_program_prefix} \
426 ${common_objpfx}posix/globtest -q -t "$testdir" "~" |
427 sort >$testout
428 echo ~ | $CMP - $testout >> $logfile || failed=1
429 if test $failed -ne 0; then
430 if test -d ~; then
431 echo "Tilde test failed" >> $logfile
432 result=1
433 else
434 echo "Tilde test could not be run" >> $logfile
438 # Test tilde expansion with trailing slash
439 failed=0
440 ${test_program_prefix} \
441 ${common_objpfx}posix/globtest -q -t "$testdir" "~/" |
442 sort > $testout
443 # Some shell incorrectly(?) convert ~/ into // if ~ expands to /.
444 if test ~/ = //; then
445 echo / | $CMP - $testout >> $logfile || failed=1
446 else
447 echo ~/ | $CMP - $testout >> $logfile || failed=1
449 if test $failed -ne 0; then
450 if test -d ~/; then
451 echo "Tilde2 test failed" >> $logfile
452 result=1
453 else
454 echo "Tilde2 test could not be run" >> $logfile
458 # Test tilde expansion with username
459 failed=0
460 ${test_program_prefix} \
461 ${common_objpfx}posix/globtest -q -t "$testdir" "~"$USER |
462 sort > $testout
463 eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
464 if test $failed -ne 0; then
465 if eval test -d ~$USER; then
466 echo "Tilde3 test failed" >> $logfile
467 result=1
468 else
469 echo "Tilde3 test could not be run" >> $logfile
473 # Tilde expansion shouldn't match a file
474 failed=0
475 ${test_program_prefix} \
476 ${common_objpfx}posix/globtest -T "$testdir" "~file4" |
477 sort > $testout
478 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
479 GLOB_NOMATCH
481 if test $failed -ne 0; then
482 echo "Tilde4 test failed" >> $logfile
483 result=1
486 # Matching \** should only find *file6
487 failed=0
488 ${test_program_prefix} \
489 ${common_objpfx}posix/globtest "$testdir" "\**" |
490 sort > $testout
491 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
492 `*file6'
494 if test $failed -ne 0; then
495 echo "Star test failed" >> $logfile
496 result=1
499 # ... unless NOESCAPE is used, in which case it should entries with a
500 # leading \.
501 failed=0
502 ${test_program_prefix} \
503 ${common_objpfx}posix/globtest -e "$testdir" "\**" |
504 sort > $testout
505 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
506 `\file9b\'
507 `\{file8\}'
508 `\{file9\,file9b\}'
510 if test $failed -ne 0; then
511 echo "Star2 test failed" >> $logfile
512 result=1
515 # Matching \*file6 should find *file6
516 failed=0
517 ${test_program_prefix} \
518 ${common_objpfx}posix/globtest "$testdir" "\*file6" |
519 sort > $testout
520 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
521 `*file6'
523 if test $failed -ne 0; then
524 echo "Star3 test failed" >> $logfile
525 result=1
528 # GLOB_BRACE alone
529 failed=0
530 ${test_program_prefix} \
531 ${common_objpfx}posix/globtest -b "$testdir" '\{file7\,\}' |
532 sort > $testout
533 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
534 `{file7,}'
536 if test $failed -ne 0; then
537 echo "Brace4 test failed" >> $logfile
538 result=1
541 # GLOB_BRACE and GLOB_NOESCAPE
542 failed=0
543 ${test_program_prefix} \
544 ${common_objpfx}posix/globtest -b -e "$testdir" '\{file9\,file9b\}' |
545 sort > $testout
546 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
547 `\file9b\'
549 if test $failed -ne 0; then
550 echo "Brace5 test failed" >> $logfile
551 result=1
554 # Escaped comma
555 failed=0
556 ${test_program_prefix} \
557 ${common_objpfx}posix/globtest -b "$testdir" '{filea\,}' |
558 sort > $testout
559 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
560 `filea,'
562 if test $failed -ne 0; then
563 echo "Brace6 test failed" >> $logfile
564 result=1
567 # Escaped closing brace
568 failed=0
569 ${test_program_prefix} \
570 ${common_objpfx}posix/globtest -b "$testdir" '{fileb\}c}' |
571 sort > $testout
572 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
573 `fileb}c'
575 if test $failed -ne 0; then
576 echo "Brace7 test failed" >> $logfile
577 result=1
580 # Try a recursive failed search
581 failed=0
582 ${test_program_prefix} \
583 ${common_objpfx}posix/globtest -e "$testdir" "a*/*" |
584 sort > $testout
585 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
586 GLOB_NOMATCH
588 if test $failed -ne 0; then
589 echo "Star4 test failed" >> $logfile
590 result=1
593 # ... with GLOB_ERR
594 failed=0
595 ${test_program_prefix} \
596 ${common_objpfx}posix/globtest -E "$testdir" "a*/*" |
597 sort > $testout
598 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
599 GLOB_NOMATCH
601 if test $failed -ne 0; then
602 echo "Star5 test failed" >> $logfile
603 result=1
606 # Try a recursive search in unreadable directory
607 failed=0
608 ${test_program_prefix} \
609 ${common_objpfx}posix/globtest "$testdir" "noread/*" |
610 sort > $testout
611 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
612 GLOB_NOMATCH
614 if test $failed -ne 0; then
615 echo "Star6 test failed" >> $logfile
616 result=1
619 failed=0
620 ${test_program_prefix} \
621 ${common_objpfx}posix/globtest "$testdir" "noread*/*" |
622 sort > $testout
623 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
624 GLOB_NOMATCH
626 if test $failed -ne 0; then
627 echo "Star6 test failed" >> $logfile
628 result=1
631 # The following tests will fail if run as root.
632 user=`id -un 2> /dev/null`
633 if test -z "$user"; then
634 uid="$USER"
636 if test "$user" != root; then
637 # ... with GLOB_ERR
638 ${test_program_prefix} \
639 ${common_objpfx}posix/globtest -E "$testdir" "noread/*" |
640 sort > $testout
641 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
642 GLOB_ABORTED
645 ${test_program_prefix} \
646 ${common_objpfx}posix/globtest -E "$testdir" "noread*/*" |
647 sort > $testout
648 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
649 GLOB_ABORTED
651 if test $failed -ne 0; then
652 echo "GLOB_ERR test failed" >> $logfile
653 result=1
655 fi # not run as root
657 # Try multiple patterns (GLOB_APPEND)
658 failed=0
659 ${test_program_prefix} \
660 ${common_objpfx}posix/globtest "$testdir" "file1" "*/*" |
661 sort > $testout
662 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
663 `dir1/file1_1'
664 `dir1/file1_2'
665 `file1'
666 `link1/file1_1'
667 `link1/file1_2'
669 if test $failed -ne 0; then
670 echo "GLOB_APPEND test failed" >> $logfile
671 result=1
674 # Try multiple patterns (GLOB_APPEND) with offset (GLOB_DOOFFS)
675 failed=0
676 ${test_program_prefix} \
677 ${common_objpfx}posix/globtest -o "$testdir" "file1" "*/*" |
678 sort > $testout
679 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
680 `abc'
681 `dir1/file1_1'
682 `dir1/file1_2'
683 `file1'
684 `link1/file1_1'
685 `link1/file1_2'
687 if test $failed -ne 0; then
688 echo "GLOB_APPEND2 test failed" >> $logfile
689 result=1
692 # Test NOCHECK with non-existing file in subdir.
693 failed=0
694 ${test_program_prefix} \
695 ${common_objpfx}posix/globtest -c "$testdir" "*/blahblah" |
696 sort > $testout
697 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
698 `*/blahblah'
700 if test $failed -ne 0; then
701 echo "No check2 test failed" >> $logfile
702 result=1
705 # Test [[:punct:]] not matching leading period.
706 failed=0
707 ${test_program_prefix} \
708 ${common_objpfx}posix/globtest -c "$testdir" "[[:punct:]]*" |
709 sort > $testout
710 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
711 `*file6'
712 `-file3'
713 `\file9b\'
714 `\{file8\}'
715 `\{file9\,file9b\}'
716 `{file7,}'
717 `~file4'
719 if test $failed -ne 0; then
720 echo "Punct test failed" >> $logfile
721 result=1
724 mkdir $testdir/'dir3*'
725 echo 1 > $testdir/'dir3*'/file1
726 mkdir $testdir/'dir4[a'
727 echo 2 > $testdir/'dir4[a'/file1
728 echo 3 > $testdir/'dir4[a'/file2
729 mkdir $testdir/'dir5[ab]'
730 echo 4 > $testdir/'dir5[ab]'/file1
731 echo 5 > $testdir/'dir5[ab]'/file2
732 mkdir $testdir/dir6
733 echo 6 > $testdir/dir6/'file1[a'
734 echo 7 > $testdir/dir6/'file1[ab]'
735 failed=0
736 v=`${test_program_prefix} \
737 ${common_objpfx}posix/globtest "$testdir" 'dir3\*/file2'`
738 test "$v" != 'GLOB_NOMATCH' && echo "$v" >> $logfile && failed=1
739 ${test_program_prefix} \
740 ${common_objpfx}posix/globtest -c "$testdir" \
741 'dir3\*/file1' 'dir3\*/file2' 'dir1/file\1_1' 'dir1/file\1_9' \
742 'dir2\/' 'nondir\/' 'dir4[a/fil*1' 'di*r4[a/file2' 'dir5[ab]/file[12]' \
743 'dir6/fil*[a' 'dir*6/file1[a' 'dir6/fi*l[ab]' 'dir*6/file1[ab]' \
744 'dir6/file1[[.a.]*' |
745 sort > $testout
746 cat <<"EOF" | $CMP - $testout >> $logfile || failed=1
747 `dir*6/file1[ab]'
748 `dir1/file1_1'
749 `dir1/file\1_9'
750 `dir2/'
751 `dir3*/file1'
752 `dir3\*/file2'
753 `dir4[a/file1'
754 `dir4[a/file2'
755 `dir5[ab]/file[12]'
756 `dir6/fi*l[ab]'
757 `dir6/file1[a'
758 `dir6/file1[a'
759 `dir6/file1[a'
760 `dir6/file1[ab]'
761 `nondir\/'
763 ${test_wrapper_env} \
764 HOME="$testdir" \
765 ${test_via_rtld_prefix} \
766 ${common_objpfx}posix/globtest -ct "$testdir" \
767 '~/dir1/file1_1' '~/dir1/file1_9' '~/dir3\*/file1' '~/dir3\*/file2' \
768 '~\/dir1/file1_2' |
769 sort > $testout
770 cat <<EOF | $CMP - $testout >> $logfile || failed=1
771 \`$testdir/dir1/file1_1'
772 \`$testdir/dir1/file1_2'
773 \`$testdir/dir3*/file1'
774 \`~/dir1/file1_9'
775 \`~/dir3\\*/file2'
777 if eval test -d ~"$USER"/; then
778 user=`echo "$USER" | sed -n -e 's/^\([^\\]\)\([^\\][^\\]*\)$/~\1\\\\\2/p'`
779 if test -n "$user"; then
780 ${test_program_prefix} \
781 ${common_objpfx}posix/globtest -ctq "$testdir" "$user/" |
782 sort > $testout
783 eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1
784 ${test_program_prefix} \
785 ${common_objpfx}posix/globtest -ctq "$testdir" "$user\\/" |
786 sort > $testout
787 eval echo ~$USER/ | $CMP - $testout >> $logfile || failed=1
788 ${test_program_prefix} \
789 ${common_objpfx}posix/globtest -ctq "$testdir" "$user" |
790 sort > $testout
791 eval echo ~$USER | $CMP - $testout >> $logfile || failed=1
794 if test $failed -ne 0; then
795 echo "Escape tests failed" >> $logfile
796 result=1
799 if test $result -eq 0; then
800 chmod 777 $testdir/noread
801 rm -fr $testdir $testout
802 echo "All OK." > $logfile
805 exit $result
807 # Preserve executable bits for this shell script.
808 Local Variables:
809 eval:(defun frobme () (set-file-modes buffer-file-name file-mode))
810 eval:(make-local-variable 'file-mode)
811 eval:(setq file-mode (file-modes (buffer-file-name)))
812 eval:(make-local-variable 'after-save-hook)
813 eval:(add-hook 'after-save-hook 'frobme)
814 End: