File: test_cmdline.cmd

package info (click to toggle)
wine 5.0.3-3
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 220,300 kB
  • sloc: ansic: 3,035,623; perl: 19,098; yacc: 16,358; makefile: 10,088; javascript: 9,150; objc: 6,590; lex: 5,734; python: 1,914; cpp: 1,042; sh: 759; java: 749; xml: 557; awk: 69; cs: 17
file content (273 lines) | stat: -rw-r--r-- 6,442 bytes parent folder | download | duplicates (9)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
@echo off
mkdir foobar
cd foobar
echo file1 > file1

rem Basic test of command line. Note a section prefix per command
rem to resync, as wine does not output anything in these cases yet.
echo --- Test 1
cmd.exe /c echo Line1
cmd.exe /c echo "Line2"
echo --- Test 2
cmd.exe /c echo Test quotes "&" work
echo --- Test 3
cmd.exe /c echo "&"
echo --- Test 4
cmd.exe /c echo "<"
echo --- Test 5
cmd.exe /c echo ">"
echo --- Test 6
cmd.exe /c echo "\"
echo --- Test 7
cmd.exe /c echo "|"
echo --- Test 8
cmd.exe /c echo "`"
echo --- Test 9
cmd.exe /c echo """
echo --- Test 10
echo on > file3
@type file3
@echo off
echo --- Test 11
cmd.exe /c echo on >file3
@type file3
@echo off
echo --- Test 12
cmd.exe /c "echo passed1"
echo --- Test 13
cmd.exe /c " echo passed2 "
echo --- Test 14
cmd.exe /c "dir /ad ..\fooba* /b"
echo --- Test 15
cmd.exe /cecho No whitespace
echo --- Test 16
cmd.exe /c
echo --- Test 17
cmd.exe /c@space@
echo --- Test 18
rem Ensure no interactive prompting when cmd.exe /c or /k
echo file2 > file2
cmd.exe /c copy file1 file2 >nul
echo No prompts or I would not get here1
rem - Try cmd.exe /k as well
cmd.exe /k "copy file1 file2 >nul && exit"
echo No prompts or I would not get here2

rem Nonexistent variable expansion is as per command line, i.e. left as-is
cmd.exe /c echo %%hello1%%
cmd.exe /c echo %%hello2
cmd.exe /c echo %%hello3^:h=t%%
cmd.exe /c echo %%hello4%%%%

rem Cannot issue a call from cmd.exe /c
cmd.exe /c call :hello5

rem %1-9 has no meaning
cmd.exe /c echo one = %%1

rem for loop vars need expanding
cmd.exe /c for /L %%i in (1,1,5) do @echo %%i

rem goto's are ineffective
cmd.exe /c goto :fred
cmd.exe /c goto eof

rem - %var% is expanded at read time, not execute time
set var=11
cmd.exe /c "set var=22 && setlocal && set var=33 && endlocal && echo var contents: %%var%%"

rem - endlocal ineffective on cmd.exe /c lines
cmd.exe /c "set var=22 && setlocal && set var=33 && endlocal && set var"
set var=99

rem - Environment is inherited ok
cmd.exe /c ECHO %%VAR%%

rem - Exit works
cmd.exe /c exit

cd ..
rd foobar /s /q

rem - Temporary batch files
echo @echo 0 > "say.bat"
echo @echo 1 > "say one.bat"
echo @echo 2 > "saytwo.bat"
echo @echo 3 > "say (3).bat"
echo @echo 4 > "say .bat"
echo @echo 5 > "bazbaz(5).bat"

echo ------ Testing invocation of batch files ----------
call say one
call "say one"
call "say"" one"
call "say one
call :setError 0
call say" one"
if errorlevel 2 echo error %ErrorLevel%
call say "one"
call :setError 0
call s"ay one
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call s"aytwo
if errorlevel 2 echo error %ErrorLevel%
call say (3)
call "say (3)"
call :setError 0
call say" (3)"
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call say" "(3) prints 4?!
if errorlevel 2 echo error %ErrorLevel%

echo ------ Testing invocation with CMD /C -------------
cmd /c say one
cmd /c "say one"
call :setError 0
cmd /c "say"" one"
if errorlevel 2 echo error %ErrorLevel%
cmd /c "say one
call :setError 0
cmd /c say" one"
if errorlevel 2 echo error %ErrorLevel%
cmd /c say "one"
call :setError 0
cmd /c s"ay one
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
cmd /c s"aytwo
if errorlevel 2 echo error %ErrorLevel%
cmd /c say (3)
call :setError 0
cmd /c say" (3)"
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
cmd /c say" "(3) prints 4?!
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
rem Deliberately invoking a fully qualified batch name containing a bracket
rem should fail, as a bracket is a command delimiter.
cmd /c "bazbaz(5).bat"
if errorlevel 1 echo Passed

echo ---------- Testing CMD /C quoting -----------------
cmd /c @echo "hi"
call :setError 0
cmd /c say" "one
if errorlevel 2 echo error %ErrorLevel%
cmd /c @echo "\"\\"\\\"\\\\" "\"\\"\\\"\\\\"
rem ---- all 5 conditions met, quotes preserved
cmd /c "say one"
rem cond 1 - /s
cmd /s/c "say one"
cmd /s/c ""say one""
rem cond 2 - not 2 quotes
cmd /c "say one
call :setError 0
cmd /c "say"" one"
if errorlevel 2 echo error %ErrorLevel%
rem cond 3 - special char - first test fails on Vista, W2K8!
cmd /c "say (3)"
cmd /c ""say (3)""
rem cond 4 - no spaces (quotes make no difference here)
cmd /c saytwo
cmd /c "saytwo"
cmd /c "saytwo
rem cond 5 - string between quotes must be name of executable
cmd /c "say five"
echo @echo 5 >"say five.bat"
cmd /c "say five"

echo ------- Testing CMD /C qualifier treatment ------------
rem no need for space after /c
cmd /csay one
cmd /c"say one"
rem ignore quote before qualifier
rem FIXME the next command in wine starts a sub-CMD
echo THIS FAILS: cmd "/c"say one
rem ignore anything before /c
rem FIXME the next command in wine starts a sub-CMD
echo THIS FAILS: cmd ignoreme/c say one

echo --------- Testing special characters --------------
echo @echo amp > "say&.bat"
call say&
echo @echo ( > "say(.bat"
call say(
echo @echo ) > "say).bat"
call say)
echo @echo [ > "say[.bat"
call say[
echo @echo ] > "say].bat"
call say]
echo @echo { > "say{.bat"
call say{
echo @echo } > "say}.bat"
call say}
echo @echo = > "say=.bat"
call say=
echo @echo sem > "say;.bat"
call say;
setlocal DisableDelayedExpansion
echo @echo ! > "say!.bat"
call say!
endlocal
setlocal EnableDelayedExpansion
call say!
endlocal
echo @echo %%%% > "say%%.bat"
call say%%
echo @echo ' > "say'.bat"
call say'
echo @echo + > "say+.bat"
call say+
echo @echo com > "say,.bat"
call say,
echo @echo ` > "say`.bat"
call say'
echo @echo ~ > "say~.bat"
call say~

echo --------- Testing parameter passing  --------------
echo @echo 1:%%1,2:%%2 > tell.bat
call tell 1
call tell (1)
call tell 1(2)
call :setError 0
call tell(1)
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell((1))
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell(1)(2)
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell(1);,;(2)
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell;1 2
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell; 1, ;2
if errorlevel 2 echo error %ErrorLevel%
call :setError 0
call tell;1;;2
if errorlevel 2 echo error %ErrorLevel%
call tell "p "1 p" "2
call tell p"1 p";2

echo --------- Testing delimiters and parameter passing  --------------
echo @echo 0:%%0,1:%%1,2:%%2,All:'%%*'> tell.bat
call;tell 1 2
call   tell 1 2
==call==tell==1==2
call tell(1234)
call tell(12(34)
call tell(12;34)
echo --------- Finished  --------------
del tell.bat say*.* bazbaz*.bat
exit
:setError
exit /B %1