d2d1: Remove unused D3D10 interfaces.
[wine.git] / programs / cmd / tests / test_cmdline.cmd
blob8712f05f87d272e81d3c7a1e402ad73029bd95fb
1 @echo off
2 mkdir foobar
3 cd foobar
4 echo file1 > file1
6 rem Basic test of command line. Note a section prefix per command
7 rem to resync, as wine does not output anything in these cases yet.
8 echo --- Test 1
9 cmd.exe /c echo Line1
10 cmd.exe /c echo "Line2"
11 echo --- Test 2
12 cmd.exe /c echo Test quotes "&" work
13 echo --- Test 3
14 cmd.exe /c echo "&"
15 echo --- Test 4
16 cmd.exe /c echo "<"
17 echo --- Test 5
18 cmd.exe /c echo ">"
19 echo --- Test 6
20 cmd.exe /c echo "\"
21 echo --- Test 7
22 cmd.exe /c echo "|"
23 echo --- Test 8
24 cmd.exe /c echo "`"
25 echo --- Test 9
26 cmd.exe /c echo """
27 echo --- Test 10
28 echo on > file3
29 @type file3
30 @echo off
31 echo --- Test 11
32 cmd.exe /c echo on >file3
33 @type file3
34 @echo off
35 echo --- Test 12
36 cmd.exe /c "echo passed1"
37 echo --- Test 13
38 cmd.exe /c " echo passed2 "
39 echo --- Test 14
40 cmd.exe /c "dir /ad ..\fooba* /b"
41 echo --- Test 15
42 cmd.exe /cecho No whitespace
43 echo --- Test 16
44 cmd.exe /c
45 echo --- Test 17
46 cmd.exe /c@space@
47 echo --- Test 18
48 rem Ensure no interactive prompting when cmd.exe /c or /k
49 echo file2 > file2
50 cmd.exe /c copy file1 file2 >nul
51 echo No prompts or I would not get here1
52 rem - Try cmd.exe /k as well
53 cmd.exe /k "copy file1 file2 >nul && exit"
54 echo No prompts or I would not get here2
56 rem Nonexistent variable expansion is as per command line, i.e. left as-is
57 cmd.exe /c echo %%hello1%%
58 cmd.exe /c echo %%hello2
59 cmd.exe /c echo %%hello3^:h=t%%
60 cmd.exe /c echo %%hello4%%%%
62 rem Cannot issue a call from cmd.exe /c
63 cmd.exe /c call :hello5
65 rem %1-9 has no meaning
66 cmd.exe /c echo one = %%1
68 rem for loop vars need expanding
69 cmd.exe /c for /L %%i in (1,1,5) do @echo %%i
71 rem goto's are ineffective
72 cmd.exe /c goto :fred
73 cmd.exe /c goto eof
75 rem - %var% is expanded at read time, not execute time
76 set var=11
77 cmd.exe /c "set var=22 && setlocal && set var=33 && endlocal && echo var contents: %%var%%"
79 rem - endlocal ineffective on cmd.exe /c lines
80 cmd.exe /c "set var=22 && setlocal && set var=33 && endlocal && set var"
81 set var=99
83 rem - Environment is inherited ok
84 cmd.exe /c ECHO %%VAR%%
86 rem - Exit works
87 cmd.exe /c exit
89 cd ..
90 rd foobar /s /q
92 rem - Temporary batch files
93 echo @echo 0 > "say.bat"
94 echo @echo 1 > "say one.bat"
95 echo @echo 2 > "saytwo.bat"
96 echo @echo 3 > "say (3).bat"
97 echo @echo 4 > "say .bat"
98 echo @echo 5 > "bazbaz(5).bat"
100 echo ------ Testing invocation of batch files ----------
101 call say one
102 call "say one"
103 call "say"" one"
104 call "say one
105 call :setError 0
106 call say" one"
107 if errorlevel 2 echo error %ErrorLevel%
108 call say "one"
109 call :setError 0
110 call s"ay one
111 if errorlevel 2 echo error %ErrorLevel%
112 call :setError 0
113 call s"aytwo
114 if errorlevel 2 echo error %ErrorLevel%
115 call say (3)
116 call "say (3)"
117 call :setError 0
118 call say" (3)"
119 if errorlevel 2 echo error %ErrorLevel%
120 call :setError 0
121 call say" "(3) prints 4?!
122 if errorlevel 2 echo error %ErrorLevel%
124 echo ------ Testing invocation with CMD /C -------------
125 cmd /c say one
126 cmd /c "say one"
127 call :setError 0
128 cmd /c "say"" one"
129 if errorlevel 2 echo error %ErrorLevel%
130 cmd /c "say one
131 call :setError 0
132 cmd /c say" one"
133 if errorlevel 2 echo error %ErrorLevel%
134 cmd /c say "one"
135 call :setError 0
136 cmd /c s"ay one
137 if errorlevel 2 echo error %ErrorLevel%
138 call :setError 0
139 cmd /c s"aytwo
140 if errorlevel 2 echo error %ErrorLevel%
141 cmd /c say (3)
142 call :setError 0
143 cmd /c say" (3)"
144 if errorlevel 2 echo error %ErrorLevel%
145 call :setError 0
146 cmd /c say" "(3) prints 4?!
147 if errorlevel 2 echo error %ErrorLevel%
148 call :setError 0
149 rem Deliberately invoking a fully qualified batch name containing a bracket
150 rem should fail, as a bracket is a command delimiter.
151 cmd /c "bazbaz(5).bat"
152 if errorlevel 1 echo Passed
154 echo ---------- Testing CMD /C quoting -----------------
155 cmd /c @echo "hi"
156 call :setError 0
157 cmd /c say" "one
158 if errorlevel 2 echo error %ErrorLevel%
159 cmd /c @echo "\"\\"\\\"\\\\" "\"\\"\\\"\\\\"
160 rem ---- all 5 conditions met, quotes preserved
161 cmd /c "say one"
162 rem cond 1 - /s
163 cmd /s/c "say one"
164 cmd /s/c ""say one""
165 rem cond 2 - not 2 quotes
166 cmd /c "say one
167 call :setError 0
168 cmd /c "say"" one"
169 if errorlevel 2 echo error %ErrorLevel%
170 rem cond 3 - special char - first test fails on Vista, W2K8!
171 cmd /c "say (3)"
172 cmd /c ""say (3)""
173 rem cond 4 - no spaces (quotes make no difference here)
174 cmd /c saytwo
175 cmd /c "saytwo"
176 cmd /c "saytwo
177 rem cond 5 - string between quotes must be name of executable
178 cmd /c "say five"
179 echo @echo 5 >"say five.bat"
180 cmd /c "say five"
181 rem cond 6 - && between quotes
182 cd .&&"cmd.exe" /c "echo hi"
183 cd "."&&cmd.exe /c "echo hi"
184 cd "."&&"cmd.exe" /c "echo hi"
186 echo ------- Testing CMD /C qualifier treatment ------------
187 rem no need for space after /c
188 cmd /csay one
189 cmd /c"say one"
190 cmd /c"say one
191 cmd /c=say one
192 cmd /c,say one
193 cmd /c;say one
194 rem non-options are ignored before /c; quotes are not treated specially
195 cmd "/c"say one
196 cmd ignoreme/c say one
197 cmd abc "def ghi/c say one"
198 cmd -\@$*'"/c say one
199 echo echo bar > foo.bat
200 cmd /qq/c foo
201 cmd /q "xyz /c foo"
202 del foo.bat
204 echo --------- Testing special characters --------------
205 echo @echo amp > "say&.bat"
206 call say&
207 echo @echo ( > "say(.bat"
208 call say(
209 echo @echo ) > "say).bat"
210 call say)
211 echo @echo [ > "say[.bat"
212 call say[
213 echo @echo ] > "say].bat"
214 call say]
215 echo @echo { > "say{.bat"
216 call say{
217 echo @echo } > "say}.bat"
218 call say}
219 echo @echo = > "say=.bat"
220 call say=
221 echo @echo sem > "say;.bat"
222 call say;
223 setlocal DisableDelayedExpansion
224 echo @echo ! > "say!.bat"
225 call say!
226 endlocal
227 setlocal EnableDelayedExpansion
228 call say!
229 endlocal
230 echo @echo %%%% > "say%%.bat"
231 call say%%
232 echo @echo ' > "say'.bat"
233 call say'
234 echo @echo + > "say+.bat"
235 call say+
236 echo @echo com > "say,.bat"
237 call say,
238 echo @echo ` > "say`.bat"
239 call say'
240 echo @echo ~ > "say~.bat"
241 call say~
243 echo --------- Testing parameter passing --------------
244 echo @echo 1:%%1,2:%%2 > tell.bat
245 call tell 1
246 call tell (1)
247 call tell 1(2)
248 call :setError 0
249 call tell(1)
250 if errorlevel 2 echo error %ErrorLevel%
251 call :setError 0
252 call tell((1))
253 if errorlevel 2 echo error %ErrorLevel%
254 call :setError 0
255 call tell(1)(2)
256 if errorlevel 2 echo error %ErrorLevel%
257 call :setError 0
258 call tell(1);,;(2)
259 if errorlevel 2 echo error %ErrorLevel%
260 call :setError 0
261 call tell;1 2
262 if errorlevel 2 echo error %ErrorLevel%
263 call :setError 0
264 call tell; 1, ;2
265 if errorlevel 2 echo error %ErrorLevel%
266 call :setError 0
267 call tell;1;;2
268 if errorlevel 2 echo error %ErrorLevel%
269 call tell "p "1 p" "2
270 call tell p"1 p";2
272 echo --------- Testing delimiters and parameter passing --------------
273 echo @echo 0:%%0,1:%%1,2:%%2,All:'%%*'> tell.bat
274 call;tell 1 2
275 call tell 1 2
276 ==call==tell==1==2
277 call tell(1234)
278 call tell(12(34)
279 call tell(12;34)
280 echo --------- Finished --------------
281 del tell.bat say*.* bazbaz*.bat
282 exit
283 :setError
284 exit /B %1