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