Test that field-splitting is performed expanding positional parameter.
[kopensolaris-gnu/glibc.git] / posix / wordexp-tst.sh
1 #!/bin/sh
2
3 # Some of these tests may look a little weird.
4 # The first parameter to wordexp-test is what it gives to wordexp.
5 # The others are just there to be parameters.
6
7 common_objpfx=$1; shift
8 elf_objpfx=$1; shift
9 rtld_installed_name=$1; shift
10
11 : ${TMPDIR=/tmp}
12 testout=$TMPDIR/wordexp-test-result
13
14 failed=0
15 export IFS=$(echo -e " \t\n")
16
17 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
18 ${common_objpfx}posix/wordexp-test '$*' > ${testout}1
19 cat <<"EOF" | cmp - ${testout}1 || failed=1
20 wordexp returned 0
21 we_wordv[0] = "$*"
22 EOF
23
24 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
25 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
26 cat <<"EOF" | cmp - ${testout}2 || failed=1
27 wordexp returned 0
28 we_wordv[0] = "${*}"
29 we_wordv[1] = "unquoted"
30 EOF
31
32 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
33 ${common_objpfx}posix/wordexp-test '$@' unquoted > ${testout}3
34 cat <<"EOF" | cmp - ${testout}3 || failed=1
35 wordexp returned 0
36 we_wordv[0] = "$@"
37 we_wordv[1] = "unquoted"
38 EOF
39
40 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
41 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
42 cat <<"EOF" | cmp - ${testout}4 || failed=1
43 wordexp returned 0
44 we_wordv[0] = ""$* quoted" param quoted"
45 EOF
46
47 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
48 ${common_objpfx}posix/wordexp-test '"$@ quoted"' param > ${testout}5
49 cat <<"EOF" | cmp - ${testout}5 || failed=1
50 wordexp returned 0
51 we_wordv[0] = ""$@ quoted""
52 we_wordv[1] = "param quoted"
53 EOF
54 # Why?  Because bash does it that way..
55
56 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
57 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
58 cat <<"EOF" | cmp - ${testout}6 || failed=1
59 wordexp returned 0
60 we_wordv[0] = "5"
61 EOF
62
63 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
64 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
65 cat <<"EOF" | cmp - ${testout}7 || failed=1
66 wordexp returned 0
67 we_wordv[0] = "2nd"
68 we_wordv[1] = "3rd"
69 we_wordv[2] = "4"
70 we_wordv[3] = "th"
71 EOF
72
73 exit $failed