]> git.ipfire.org Git - thirdparty/bash.git/blob - tests/new-exp.tests
Imported from ../bash-1.14.7.tar.gz.
[thirdparty/bash.git] / tests / new-exp.tests
1 expect()
2 {
3 echo expect "$@"
4 }
5
6 HOME=/usr/homes/chet # to make the check against new-exp.right work
7 expect '<foo bar>'
8 recho "${undef-"foo bar"}" # should be foo bar
9 expect '<foo>'
10 recho "${und="foo"}" # should be foo
11
12 expect "<$HOME>"
13 recho ${HOME-"}"}
14 expect "<$HOME>"
15 recho "${HOME-'}'}"
16 expect "<$HOME>"
17 recho "${HOME-"}"}"
18
19 expect $0: '${HOME:`echo }`}: bad substitution'
20 recho "${HOME:`echo }`}" # should be an error -- bad substitution
21
22 expect $0: '${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]}: bad substitution'
23 x=${_ENV[(_$-=0)+(_=1)-_${-%%*i*}]} # memory leak
24
25 expect "<$HOME>"
26 recho ${HOME}
27 expect "<$HOME>"
28 recho ${HOME:-`echo }`}
29 expect "<$HOME>"
30 recho ${HOME:-`echo "}"`}
31 expect "<$HOME>"
32 recho "${HOME:-`echo "}"`}"
33 expect "<$HOME>"
34 recho "$(echo "${HOME}")"
35 expect "<$HOME>"
36 recho "$(echo "$(echo ${HOME})")"
37 expect "<$HOME>"
38 recho "$(echo "$(echo "${HOME}")")"
39
40 P=*@*
41 expect '<*@>'
42 recho "${P%"*"}" # should be *@
43 expect '<@*>'
44 recho "${P#\*}" # should be @*
45
46 expect '<)>'
47 recho "$(echo ")")" # should be )
48 expect '<")">'
49 recho "$(echo "\")\"")" # should be ")"
50
51 foo='abcd '
52 expect '<-abcd> <->'
53 recho -${foo}- # should be -abcd -
54 expect '<-abcd> <->'
55 recho -${foo% *}- # should be -abcd -
56 expect '<-abcd->'
57 recho -${foo%% *}- # should be -abcd-
58
59 set a b c d e
60 expect '<a b c d e>'
61 IFS=""
62 recho "$@"
63 IFS='
64 '
65
66 foo=bar
67 expect '<bar foo>'
68 echo -n $foo' ' ; echo foo
69
70 expect '<bar foo>'
71 echo -n $foo" " ; echo foo
72
73 expect '<bar foo>'
74 echo -n "$foo " ; echo foo
75
76 expect '<bar foo>'
77 echo -e "$foo\c " ; echo foo
78
79 expect '<bar foo>'
80 echo -e $foo"\c " ; echo foo
81
82 set -u
83 expect $0: ABX: unbound variable
84 recho ${ABX}
85 set +u
86
87 expect $0: '$6: cannot assign in this way'
88 recho ${6="arg6"}
89
90 expect a newline
91 echo $abmcde
92
93 # this must be last!
94 expect $0: 'ABXD: parameter unset'
95 recho ${ABXD:?"parameter unset"}