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.
10 cmd.exe
/c
echo "Line2"
12 cmd.exe
/c
echo Test quotes
"&" work
32 cmd.exe
/c
echo on
>file3
36 cmd.exe
/c
"echo passed1"
38 cmd.exe
/c
" echo passed2 "
40 cmd.exe
/c
"dir /ad ..\fooba* /b"
42 cmd.exe
/cecho No whitespace
48 rem Ensure no interactive prompting when cmd.exe /c or /k
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
75 rem - %var% is expanded at read time, not execute time
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"
83 rem - Environment is inherited ok
84 cmd.exe
/c
ECHO %%VAR%%
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 ----------
107 if errorlevel 2 echo error %ErrorLevel%
111 if errorlevel 2 echo error
%ErrorLevel%
114 if errorlevel 2 echo error %ErrorLevel%
119 if errorlevel 2 echo error %ErrorLevel%
121 call say" "(3) prints 4?!
122 if errorlevel 2 echo error %ErrorLevel%
124 echo ------ Testing invocation with CMD /C -------------
129 if errorlevel 2 echo error %ErrorLevel%
133 if errorlevel 2 echo error
%ErrorLevel%
137 if errorlevel 2 echo error %ErrorLevel%
140 if errorlevel 2 echo error
%ErrorLevel%
144 if errorlevel 2 echo error
%ErrorLevel%
146 cmd /c
say" "(3) prints
4?
!
147 if errorlevel 2 echo error
%ErrorLevel%
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
-----------------
158 if errorlevel 2 echo error
%ErrorLevel%
159 cmd /c @
echo "\"\\"\\\"\\\\" "\"\\"\\\"\\\\"
160 rem ---- all 5 conditions met, quotes preserved
165 rem cond 2 - not 2 quotes
169 if errorlevel 2 echo error %ErrorLevel%
170 rem cond 3 - special char - first test fails on Vista, W2K8!
173 rem cond 4 - no spaces (quotes make no difference here)
177 rem cond 5 - string between quotes must be name of executable
179 echo @
echo 5 >"say five.bat"
182 echo ------- Testing
CMD /C qualifier treatment
------------
183 rem no need for space after /c
186 rem ignore quote before qualifier
187 rem FIXME the next command in wine starts a sub-CMD
188 echo THIS FAILS
: cmd "/c"say one
189 rem ignore anything before /c
190 rem FIXME the next command in wine starts a sub-CMD
191 echo THIS FAILS
: cmd ignoreme
/c
say one
193 echo --------- Testing special characters
--------------
194 echo @
echo amp
> "say&.bat"
196 echo @
echo ( > "say(.bat"
198 echo @
echo ) > "say).bat"
200 echo @
echo [ > "say[.bat"
202 echo @
echo ] > "say].bat"
204 echo @
echo { > "say{.bat"
206 echo @
echo } > "say}.bat"
208 echo @
echo = > "say=.bat"
210 echo @
echo sem
> "say;.bat"
212 setlocal DisableDelayedExpansion
213 echo @
echo ! > "say!.bat"
216 setlocal EnableDelayedExpansion
219 echo @
echo %%%% > "say%%.bat"
221 echo @
echo ' > "say'.bat
"
223 echo @echo + > "say+.bat
"
225 echo @echo com > "say,.bat
"
227 echo @echo ` > "say`.bat
"
229 echo @echo ~ > "say~.bat
"
232 echo --------- Testing parameter passing --------------
233 echo @echo 1:%%1,2:%%2 > tell.bat
239 if errorlevel 2 echo error %ErrorLevel%
242 if errorlevel 2 echo error %ErrorLevel%
245 if errorlevel 2 echo error %ErrorLevel%
248 if errorlevel 2 echo error %ErrorLevel%
251 if errorlevel 2 echo error %ErrorLevel%
254 if errorlevel 2 echo error %ErrorLevel%
257 if errorlevel 2 echo error %ErrorLevel%
258 call tell "p
"1 p" "2
261 echo --------- Testing delimiters and parameter passing --------------
262 echo @echo 0:%%0,1:%%1,2:%%2,All:'%%*'> tell.bat
269 echo --------- Finished --------------
270 del tell.bat say*.* bazbaz*.bat