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"
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
194 rem non-options are ignored before /c; quotes are not treated specially
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
204 echo --------- Testing special characters
--------------
205 echo @
echo amp
> "say&.bat"
207 echo @
echo ( > "say(.bat"
209 echo @
echo ) > "say).bat"
211 echo @
echo [ > "say[.bat"
213 echo @
echo ] > "say].bat"
215 echo @
echo { > "say{.bat"
217 echo @
echo } > "say}.bat"
219 echo @
echo = > "say=.bat"
221 echo @
echo sem
> "say;.bat"
223 setlocal DisableDelayedExpansion
224 echo @
echo ! > "say!.bat"
227 setlocal EnableDelayedExpansion
230 echo @
echo %%%% > "say%%.bat"
232 echo @
echo ' > "say'.bat
"
234 echo @echo + > "say+.bat
"
236 echo @echo com > "say,.bat
"
238 echo @echo ` > "say`.bat
"
240 echo @echo ~ > "say~.bat
"
243 echo --------- Testing parameter passing --------------
244 echo @echo 1:%%1,2:%%2 > tell.bat
250 if errorlevel 2 echo error %ErrorLevel%
253 if errorlevel 2 echo error %ErrorLevel%
256 if errorlevel 2 echo error %ErrorLevel%
259 if errorlevel 2 echo error %ErrorLevel%
262 if errorlevel 2 echo error %ErrorLevel%
265 if errorlevel 2 echo error %ErrorLevel%
268 if errorlevel 2 echo error %ErrorLevel%
269 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
280 echo --------- Finished --------------
281 del tell.bat say*.* bazbaz*.bat