Change debconf text to claim that the default /bin/sh is dash instead of bash. close...
[posh.git] / tests / token.t
blob505669e43546ed28aaedbaeeb5397de639d2b3ff
1 # These tests deal with tokens.
3 name: token-1
4 description:
5         Check expansion in a quoted heredoc
6 category: debian,posix
7 stdin:
8         FULLVARIABLE="Three short words"
9         cat <<"DELIMITER"
10         One $EMPTYVARIABLE
11         Two $FULLVARIABLE
12         Three $(echo command expansion)
13         Four `echo backquote expansion`
14         Five $(( 2 + 3 ))
15         DELIMITER
16 expected-stdout:
17         One $EMPTYVARIABLE
18         Two $FULLVARIABLE
19         Three $(echo command expansion)
20         Four `echo backquote expansion`
21         Five $(( 2 + 3 ))
22 ---
23 name: token-2
24 description:
25         Check expansion in an unquoted heredoc
26 category: debian,posix
27 stdin:
28         FULLVARIABLE="Three short words"
29         cat <<DELIMITER
30         One $EMPTYVARIABLE
31         Two $FULLVARIABLE
32         Three $(echo command expansion)
33         Four `echo backquote expansion`
34         Five $(( 2 + 3 ))
35         DELIMITER
36 expected-stdout:
37         One 
38         Two Three short words
39         Three command expansion
40         Four backquote expansion
41         Five 5
42 ---
43 name: token-3
44 description:
45         Check expansion in a hyphenated heredoc
46 category: debian,posix
47 stdin:
48         FULLVARIABLE="Three short words"
49         cat <<-DELIMITER
50                 One $EMPTYVARIABLE
51                         Two $FULLVARIABLE
52                                 Three $(echo command expansion)
53                                         Four `echo backquote expansion`
54                                                 Five $(( 2 + 3 ))
55         DELIMITER
56 expected-stdout:
57         One 
58         Two Three short words
59         Three command expansion
60         Four backquote expansion
61         Five 5
62 ---
63 name: token-4
64 description:
65         Check expansion in multiple heredocs
66 category: debian,posix
67 stdin:
68         FULLVARIABLE="Three short words"
69         echo FIRST ; cat <<DELIMITER1 ; echo SECOND ; cat <<DELIMITER2 ; echo DONE
70         One $EMPTYVARIABLE
71         Two $FULLVARIABLE
72         Three $(echo command expansion)
73         Four `echo backquote expansion`
74         Five $(( 2 + 3 ))
75         DELIMITER1
76         Six $EMPTYVARIABLE
77         Seven $FULLVARIABLE
78         Eight $(echo command expansion)
79         Nine `echo backquote expansion`
80         Ten $(( 2 + 3 ))
81         DELIMITER2
82 expected-stdout:
83         FIRST
84         One 
85         Two Three short words
86         Three command expansion
87         Four backquote expansion
88         Five 5
89         SECOND
90         Six 
91         Seven Three short words
92         Eight command expansion
93         Nine backquote expansion
94         Ten 5
95         DONE
96 ---
97 name: token-5
98 description:
99         Check file redirection
100 category: debian,posix
101 stdin:
102         TEMPFILE=$(tempfile --prefix posix)
103         echo Sesame >$TEMPFILE
104         exec 8<$TEMPFILE
105         read LINE <&8
106         echo $LINE seeds
107         rm $TEMPFILE
108 expected-stdout:
109         Sesame seeds
111 name: token-6
112 description:
113         Check fd redirection
114 category: debian,posix
115 stdin:
116         exec 8>&1
117         echo Hush ; echo Puppies >&8 | cat - 8>&1
118 expected-stdout:
119         Hush
120         Puppies
122 name: token-7
123 description:
124         Check random access
125 category: debian,posix
126 stdin:
127         TEMPFILE=$(tempfile --prefix posix)
128         echo Sesame oil >$TEMPFILE
129         echo Snake oil >>$TEMPFILE
130         echo Baby oil >>$TEMPFILE
131         
132         cat $TEMPFILE
133         echo Followed by revision
134         
135         exec 8<>$TEMPFILE
136         read LINE <&8
137         echo Tahini >&8
138         read LINE <&8
139         exec 8>&-
140         
141         cat $TEMPFILE
142         
143         rm $TEMPFILE
144 expected-stdout:
145         Sesame oil
146         Snake oil
147         Baby oil
148         Followed by revision
149         Sesame oil
150         Tahini
151         il
152         Baby oil
154 name: token-8
155 description:
156         Check underscores
157 category: debian,posix
158 stdin:
159         BLAH_THIS=aglio
160         echo $BLAH_THIS
161         BLAH_THIS=olio
162         echo $BLAH_THIS
163 expected-stdout:
164         aglio
165         olio