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.
7 common_objpfx
=$1; shift
9 rtld_installed_name
=$1; shift
11 : ${TMPDIR=${common_objpfx}posix}
12 testout
=$TMPDIR/wordexp-test-result
15 # This is written in this funny way so that there is no trailing whitespace.
16 # The first line contains a space followed by a tab.
22 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
23 ${common_objpfx}posix
/wordexp-test
'$*' > ${testout}1
24 cat <<"EOF" | cmp - ${testout}1 || failed=1
29 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
30 ${common_objpfx}posix/wordexp-test '${*}' unquoted > ${testout}2
31 cat <<"EOF" |
cmp - ${testout}2 || failed
=1
34 we_wordv
[1] = "unquoted"
37 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
38 ${common_objpfx}posix
/wordexp-test
'$@' unquoted
> ${testout}3
39 cat <<"EOF" | cmp - ${testout}3 || failed=1
42 we_wordv[1] = "unquoted"
45 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
46 ${common_objpfx}posix/wordexp-test '"$* quoted"' param > ${testout}4
47 cat <<"EOF" |
cmp - ${testout}4 || failed
=1
49 we_wordv
[0] = ""$
* quoted
" param quoted"
52 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
53 ${common_objpfx}posix
/wordexp-test
'"$@ quoted"' param
> ${testout}5
54 cat <<"EOF" | cmp - ${testout}5 || failed=1
56 we_wordv[0] = ""$@ quoted""
57 we_wordv[1] = "param quoted"
59 # Why? Because bash does it that way..
61 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
62 ${common_objpfx}posix/wordexp-test '$#' 2 3 4 5 > ${testout}6
63 cat <<"EOF" |
cmp - ${testout}6 || failed
=1
68 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
69 ${common_objpfx}posix/wordexp-test '$2 ${3} $4' 2nd 3rd "4 th" > ${testout}7
70 cat <<"EOF" | cmp - ${testout}7 || failed=1
78 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
79 ${common_objpfx}posix/wordexp-test '${11}' 2 3 4 5 6 7 8 9 10 11 > ${testout}8
80 cat <<"EOF" |
cmp - ${testout}8 || failed
=1
85 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
86 ${common_objpfx}posix
/wordexp-test
'"a $@ b"' c d
> ${testout}9
87 cat <<"EOF" | cmp - ${testout}9 || failed=1
89 we_wordv[0] = "a "a $@ b""
94 ${elf_objpfx}${rtld_installed_name} --library-path ${common_objpfx} \
95 ${common_objpfx}posix/wordexp-test '${#@} ${#2} *$**' two 3 4 > ${testout}10
96 cat <<"EOF" |
cmp - ${testout}10 || failed
=1
100 we_wordv
[2] = "*${#@}"
101 we_wordv
[3] = "${#2}"