1 echo Tests for cmd's builtin commands
4 echo ------------ Testing 'echo' [ON] ------------
6 echo 'singlequotedword'
7 echo "doublequotedword"
20 echo word@space@@space@
24 echo@tab@word@tab@@space@
36 echo ------------ Testing 'echo' [OFF] ------------
38 echo 'singlequotedword'
39 echo "doublequotedword"
52 echo word@space@@space@
56 echo@tab@word@tab@@space@
62 echo ------------ Testing mixed echo modes ------------
63 echo @echo on> mixedEchoModes.cmd
64 echo if 1==1 echo foo>> mixedEchoModes.cmd
65 echo if 1==1 @echo bar>> mixedEchoModes.cmd
66 echo @echo off>> mixedEchoModes.cmd
67 echo if 1==1 echo foo2>> mixedEchoModes.cmd
68 echo if 1==1 @echo bar2>> mixedEchoModes.cmd
69 type mixedEchoModes.cmd
70 cmd /c mixedEchoModes.cmd
71 del mixedEchoModes.cmd
73 echo ------------ Testing parameterization ------------
75 call :TestParm "a b c"
76 call :TestParm "a b"\c
77 call :TestParm a=~`+,.{}!+b
81 call :TestParm a[b]{c}(d)e
82 call :TestParm a&echo second line
83 call :TestParm a b,,,c
84 call :TestParm a==b;;c
93 echo ------------ Testing rem ------------
98 rem echo foo & echo bar
101 rem@tab@echo foo & echo bar
107 rem echo foo & echo bar
110 rem@tab@echo foo & echo bar
113 echo ------------ Testing redirection operators ------------
114 mkdir foobar & cd foobar
115 echo --- stdout redirection
124 echo foo@tab@1>@tab@foo
145 echo --- stdout appending
163 echo foo7 7>> foo || (echo not supported & del foo)
164 if exist foo (type foo) else echo not supported
165 echo --- redirections within IF statements
166 if 1==1 echo foo1>bar
169 if 1==1 (echo foo2>bar) else echo baz2>bar
171 if 1==1 (echo foo3) else echo baz3>bar
172 type bar || echo file does not exist, ok
173 if 1==1 (echo foo4>bar) else echo baz4>bar
175 if 1==0 (echo foo5>bar) else echo baz5>bar
177 if 1==0 (echo foo6) else echo baz6 1>bar
179 if 1==0 (echo foo7 1>bar) else echo baz7>bar
181 if 1==0 (echo foo8 1>bar) else echo baz8>bak
183 if 1==1 (echo foo>bar & echo baz)
190 (if 1==1 (echo A) else echo B) > C
192 (if 1==0 (echo A) else echo B) > C
194 (if 1==0 (echo A > B) else echo C)
195 cd .. & rd /s/q foobar
197 echo ------------ Testing circumflex escape character ------------
198 rem Using something like "echo foo^" asks for an additional char after a "More?" prompt on the following line; it's not possible to currently test that non-interactively
220 echo bak ^&& echo baz 2> nul
228 set WINE_FOO=bar ^| baz
230 rem FIXME: echoing %WINE_FOO% gives an error (baz not recognized) but prematurely
231 rem exits the script on windows; redirecting stdout and/or stderr doesn't help
234 set WINE_FOO=bar ^^^| baz
240 echo ------------ Testing 'set' ------------
242 rem Remove any WINE_FOO* WINE_BA* environment variables from shell before proceeding
243 for /f "delims==" %%i in ('set WINE_ba') do set %%i=
244 for /f "delims==" %%i in ('set WINE_foo') do set %%i=
245 set WINE_FOOBAR 2> nul > nul
247 set WINE_FOOBAR = baz
249 echo %WINE_FOOBAR%WINE_FOOBAR not defined
251 set WINE_FOOBAR 2> nul
252 set WINE_FOOBAR = baz2
261 echo %WINE_FOOBAR%WINE_FOOBAR not defined
263 set WINE_FOOBA 2> nul > nul
269 echo %WINE_FOO%%WINE_BAR%
272 set WINE_FOO=%WINE_FOO%
273 echo %WINE_FOO%WINE_FOO not defined
278 echo set "WINE_FOO=bar" should not include the quotes in the variable value
285 set WINE_FOO=foo@space@
287 set WINE_FOO=foo@tab@
291 echo ------------ Testing variable expansion ------------
293 echo ~dp0 should be directory containing batch file
306 echo P%WINE_UNKNOWN%S
309 echo %ERRORLEVEL%%ERRORLEVEL%
310 echo %ERRORLEVEL%ERRORLEVEL%
317 echo ------------ Testing variable substrings ------------
322 echo '%WINE_VAR:~-2,3%'
323 echo '%WINE_VAR:~-2,1%'
324 echo %WINE_VAR:~2,-1%
325 echo %WINE_VAR:~2,-3%
326 echo '%WINE_VAR:~-2,-4%'
327 echo %WINE_VAR:~-3,-2%
330 echo ------------ Testing variable substitution ------------
331 echo --- in FOR variables
332 for %%i in ("A B" C) do echo %%i
333 rem check works when prefix with @
334 @for %%i in ("A B" C) do echo %%i
336 for %%i in ("A B" C) do echo '%%~i'
337 rem fully qualified path
338 for %%f in ("C D" E) do echo %%~ff
340 for %%i in ("F G" H) do echo %%~di
342 for %%d in ("I J" K) do echo %%~pd
344 for %%i in ("L M" N) do echo %%~ni
346 for %%i in ("O. P.OOL" Q.TABC hello) do echo '%%~xi'
347 rem path with short path names
348 for %%I in ("R S" T ABCDEFGHIJK.LMNOP) do echo '%%~sI'
350 for %%i in ("U V" W) do echo '%%~ai'
352 for %%i in (foo) do echo '%%~ai'
353 for %%i in (foo) do echo '%%~zi'
356 rem Not fully testable, until we can grep dir's output to get foo's creation time in an envvar...
357 for %%i in ("a b" c) do echo '%%~ti'
359 rem Similar issues as above
360 for %%i in ("a b" c) do echo '%%~zi'
362 for %%i in ("d e" f) do echo %%~dpi
363 for %%i in ("g h" i) do echo %%~sdi
364 for %%i in ("g h" i) do echo %%~dsi
365 for %%i in ("j k" l.eh) do echo '%%~xsi'
367 echo --- in parameters
368 for %%i in ("A B" C) do call :echoFun %%i
370 for %%i in ("A B" C) do call :echoFunQ %%i
371 rem fully qualified path
372 for %%f in ("C D" E) do call :echoFunF %%f
374 for %%i in ("F G" H) do call :echoFunD %%i
376 for %%d in ("I J" K) do call :echoFunP %%d
378 for %%i in ("L M" N) do call :echoFunN %%i
380 for %%i in ("O. P.OOL" Q.TABC hello) do call :echoFunX %%i
381 rem path with short path names
382 for %%I in ("R S" T ABCDEFGHIJK.LMNOP) do call :echoFunS %%I
383 rem NT4 aborts whole script execution when encountering ~a, ~t and ~z substitutions, preventing full testing
385 for %%i in ("d e" f) do call :echoFunDP %%i
386 for %%i in ("g h" i) do call :echoFunSD %%i
387 for %%i in ("g h" i) do call :echoFunDS %%i
388 for %%i in ("j k" l.eh) do call :echoFunXS %%i
420 rem some NT4 workaround
443 echo ------------ Testing variable delayed expansion ------------
444 rem NT4 doesn't support this
445 echo --- default mode (load-time expansion)
449 if %WINE_FOO% == foo (
451 if %WINE_FOO% == bar (echo bar) else echo foo
455 if %WINE_FOO% == foo (
457 if !WINE_FOO! == bar (echo bar) else echo foo
460 echo --- runtime (delayed) expansion mode
461 setlocal EnableDelayedExpansion
465 if %WINE_FOO% == foo (
467 if %WINE_FOO% == bar (echo bar) else echo foo
471 if %WINE_FOO% == foo (
473 if !WINE_FOO! == bar (echo bar) else echo foo
476 setlocal DisableDelayedExpansion
482 echo --- using /V cmd flag
483 echo @echo off> tmp.cmd
484 echo set WINE_FOO=foo>> tmp.cmd
485 echo echo %%WINE_FOO%%>> tmp.cmd
486 echo echo !WINE_FOO!>> tmp.cmd
487 echo set WINE_FOO=>> tmp.cmd
489 cmd /V:OfF /C tmp.cmd
492 echo ------------ Testing conditional execution ------------
493 echo --- unconditional ampersand
494 call :setError 123 & echo foo1
495 echo bar2 & echo foo2
496 mkdir foobar & cd foobar
498 cd .. & rd /s/q foobar
500 echo foobar not deleted!
503 ) else echo foobar deleted
504 echo --- on success conditional and
505 call :setError 456 && echo foo3 > foo3
509 ) else echo foo3 not created
510 echo bar4 && echo foo4
511 echo --- on failure conditional or
512 call :setError 789 || echo foo5
513 echo foo6 || echo bar6 > bar6
519 echo ------------ Testing cd ------------
522 echo blabla > singleFile
524 echo Current dir: %CD%
539 if not exist foobar (cd ..)
541 cd@tab@..@tab@@space@@tab@
543 if not exist foobar (cd ..)
557 cd "bar bak@space@"@tab@@space@
568 echo ------------ Testing type ------------
582 echo ------------ Testing NUL ------------
583 md foobar & cd foobar
584 rem NUL file (non) creation + case insensitivity
585 rem Note: "if exist" does not work with NUL, so to check for file existence we use a kludgy workaround
594 rem NUL not special everywhere
597 if not exist foo (echo foo should have been created) else (
601 rem Empty file creation
611 copy a.a+NUL b.b >nul
612 call :CheckFileSize a.a 7 b.b 8
613 copy NUL+a.a b.b >nul
614 call :CheckFileSize a.a 7 b.b 8
616 copy a.a+NUL subdir\ >nul
617 call :CheckFileSize a.a 7 subdir\a.a 8
621 if exist a.a echo Failed
625 cd .. & rd foobar /s /q
627 echo ------------ Testing if/else ------------
628 echo --- if/else should work with blocks
630 echo if seems to work
632 echo if seems to be broken
635 echo else seems to be broken
637 echo else seems to work
640 echo if seems not to detect /c as parameter
642 echo parameter detection seems to be broken
645 echo --- case sensitivity with and without /i option
646 if bar==BAR echo if does not default to case sensitivity
647 if not bar==BAR echo if seems to default to case sensitivity
648 if /i foo==FOO echo if /i seems to work
649 if /i not foo==FOO echo if /i seems to be broken
650 if /I foo==FOO echo if /I seems to work
651 if /I not foo==FOO echo if /I seems to be broken
653 echo --- string comparisons
654 if abc == abc (echo equal) else echo non equal
655 if abc =="abc" (echo equal) else echo non equal
656 if "abc"== abc (echo equal) else echo non equal
657 if "abc"== "abc" (echo equal) else echo non equal
659 echo --- tabs handling
660 if@tab@1==1 echo doom
661 if @tab@1==1 echo doom
662 if 1==1 (echo doom) else@tab@echo quake
663 if@tab@not @tab@1==@tab@0 @tab@echo lol
664 if 1==0@tab@(echo doom) else echo quake
665 if 1==0 (echo doom)@tab@else echo quake
666 if 1==0 (echo doom) else@tab@echo quake
668 echo --- comparison operators
669 rem NT4 misevaluates conditionals in for loops so we have to use subroutines as workarounds
670 echo ------ for strings
671 rem NT4 stops processing of the whole batch file as soon as it finds a
672 rem comparison operator non fully uppercased, such as lss instead of LSS, so we
673 rem can't test those here.
674 if LSS LSS LSSfoo (echo LSS string can be used as operand for LSS comparison)
675 if LSS LSS LSS (echo bar)
676 if 1.1 LSS 1.10 (echo floats are handled as strings)
677 if "9" LSS "10" (echo numbers in quotes recognized!) else echo numbers in quotes are handled as strings
678 if not "-1" LSS "1" (echo negative numbers as well) else echo NT4
679 if /i foo LSS FoOc echo if /i seems to work for LSS
680 if /I not foo LSS FOOb echo if /I seems to be broken for LSS
681 set WINE_STR_PARMS=A B AB BA AA
682 for %%i in (%WINE_STR_PARMS%) do (
683 for %%j in (%WINE_STR_PARMS%) do (
684 call :LSStest %%i %%j))
685 if b LSS B (echo b LSS B) else echo NT4
686 if /I b LSS B echo b LSS B insensitive
687 if b LSS A echo b LSS A
688 if /I b LSS A echo b LSS A insensitive
689 if a LSS B (echo a LSS B) else echo NT4
690 if /I a LSS B echo a LSS B insensitive
691 if A LSS b echo A LSS b
692 if /I A LSS b echo A LSS b insensitive
693 for %%i in (%WINE_STR_PARMS%) do (
694 for %%j in (%WINE_STR_PARMS%) do (
695 call :LEQtest %%i %%j))
696 if b LEQ B (echo b LEQ B) else echo NT4
697 if /I b LEQ B echo b LEQ B insensitive
698 if b LEQ A echo b LEQ A
699 if /I b LEQ A echo b LEQ A insensitive
700 if a LEQ B (echo a LEQ B) else echo NT4
701 if /I a LEQ B echo a LEQ B insensitive
702 if A LEQ b echo A LEQ b
703 if /I A LEQ b echo A LEQ b insensitive
704 for %%i in (%WINE_STR_PARMS%) do (
705 for %%j in (%WINE_STR_PARMS%) do (
706 call :EQUtest %%i %%j))
707 if /I A EQU a echo A EQU a insensitive
708 for %%i in (%WINE_STR_PARMS%) do (
709 for %%j in (%WINE_STR_PARMS%) do (
710 call :NEQtest %%i %%j))
711 for %%i in (%WINE_STR_PARMS%) do (
712 for %%j in (%WINE_STR_PARMS%) do (
713 call :GEQtest %%i %%j))
714 for %%i in (%WINE_STR_PARMS%) do (
715 for %%j in (%WINE_STR_PARMS%) do (
716 call :GTRtest %%i %%j))
717 echo ------ for numbers
718 if -1 LSS 1 (echo negative numbers handled)
719 if not -1 LSS -10 (echo negative numbers handled)
720 if not 9 LSS 010 (echo octal handled)
721 if not -010 LSS -8 (echo also in negative form)
722 if 4 LSS 0x5 (echo hexa handled)
723 if not -1 LSS -0x1A (echo also in negative form)
724 if 11 LSS 101 (echo 11 LSS 101)
725 set WINE_INT_PARMS=0 1 10 9
726 for %%i in (%WINE_INT_PARMS%) do (
727 for %%j in (%WINE_INT_PARMS%) do (
728 call :LSStest %%i %%j))
729 for %%i in (%WINE_INT_PARMS%) do (
730 for %%j in (%WINE_INT_PARMS%) do (
731 call :LEQtest %%i %%j))
732 for %%i in (%WINE_INT_PARMS%) do (
733 for %%j in (%WINE_INT_PARMS%) do (
734 call :EQUtest %%i %%j))
735 if 011 EQU 9 (echo octal ok)
736 if 0xA1 EQU 161 (echo hexa ok)
737 if 0xA1 EQU "161" (echo hexa should be recognized) else (echo string/hexa compare ok)
738 if "0xA1" EQU 161 (echo hexa should be recognized) else (echo string/hexa compare ok)
739 for %%i in (%WINE_INT_PARMS%) do (
740 for %%j in (%WINE_INT_PARMS%) do (
741 call :NEQtest %%i %%j))
742 for %%i in (%WINE_INT_PARMS%) do (
743 for %%j in (%WINE_INT_PARMS%) do (
744 call :GEQtest %%i %%j))
745 for %%i in (%WINE_INT_PARMS%) do (
746 for %%j in (%WINE_INT_PARMS%) do (
747 call :GTRtest %%i %%j))
748 echo ------ for numbers and stringified numbers
749 if not "1" EQU 1 (echo strings and integers not equal) else echo foo
750 if not 1 EQU "1" (echo strings and integers not equal) else echo foo
751 if '1' EQU 1 echo '1' EQU 1
752 if 1 EQU '1' echo 1 EQU '1'
753 if not "1" GEQ 1 (echo foo) else echo bar
754 if "10" GEQ "1" echo "10" GEQ "1"
755 if '1' GEQ 1 (echo '1' GEQ 1) else echo NT4
756 if 1 GEQ "1" echo 1 GEQ "1"
757 if "1" GEQ "1" echo "1" GEQ "1"
758 if '1' GEQ "1" echo '1' GEQ "1"
759 if "10" GEQ "1" echo "10" GEQ "1"
760 if not 1 GEQ '1' (echo non NT4) else echo 1 GEQ '1'
761 for %%i in ("1" '1') do call :GEQtest %%i '1'
762 if "10" GEQ '1' (echo "10" GEQ '1') else echo foo
763 if 1 GEQ "10" (echo 1 GEQ "10") else echo foo
764 if "1" GEQ "10" (echo 1 GEQ "10") else echo foo
765 if '1' GEQ "10" (echo '1' GEQ "10") else echo foo
766 if "10" GEQ "10" (echo "10" GEQ "10")
767 goto :endIfCompOpsSubroutines
769 rem IF subroutines helpers
771 if %1 LSS %2 echo %1 LSS %2
774 if %1 LEQ %2 echo %1 LEQ %2
777 if %1 EQU %2 echo %1 EQU %2
780 if %1 NEQ %2 echo %1 NEQ %2
783 if %1 GEQ %2 echo %1 GEQ %2
786 if %1 GTR %2 echo %1 GTR %2
789 :endIfCompOpsSubroutines
793 echo ------------ Testing for ------------
795 for %%i in (A B C) do echo %%i
796 for %%i in (A B C) do echo %%I
797 for %%i in (A B C) do echo %%j
798 for %%i in (A B C) do call :forTestFun1 %%i
799 for %%i in (1,4,1) do echo %%i
800 for %%i in (A, B,C) do echo %%i
801 for %%i in (X) do echo %%i
802 for@tab@%%i in (X2) do echo %%i
803 for %%i in@tab@(X3) do echo %%i
804 for %%i in (@tab@ foo@tab@) do echo %%i
805 for@tab@ %%i in@tab@(@tab@M) do echo %%i
806 for %%i@tab@in (X)@tab@do@tab@echo %%i
807 for@tab@ %%j in@tab@(@tab@M, N, O@tab@) do echo %%j
808 for %%i in (`echo A B`) do echo %%i
809 for %%i in ('echo A B') do echo %%i
810 for %%i in ("echo A B") do echo %%i
811 for %%i in ("A B" C) do echo %%i
817 echo --- imbricated FORs
824 for %%i in (A B) do (
825 for %%j in (C D) do (
827 for %%i in (A B) do (
828 for %%j in (C D) do (
829 call :forTestFun2 %%i %%j ))
835 mkdir foobar & cd foobar
840 echo --- basic wildcards
841 for %%i in (ba*) do echo %%i
843 for /d %%i in (baz foo bar) do echo %%i 2>&1
844 rem Confirm we don't match files:
845 for /d %%i in (bazb*) do echo %%i 2>&1
846 for /d %%i in (bazb2*) do echo %%i 2>&1
847 rem Show we pass through non wildcards
848 for /d %%i in (PASSED) do echo %%i
849 for /d %%i in (xxx) do (
850 echo %%i - Should be xxx
851 echo Expected second line
853 rem Show we issue no messages on failures
854 for /d %%i in (FAILED?) do echo %%i 2>&1
855 for /d %%i in (FAILED?) do (
856 echo %%i - Unexpected!
857 echo FAILED Unexpected second line
859 for /d %%i in (FAILED*) do echo %%i 2>&1
860 for /d %%i in (FAILED*) do (
861 echo %%i - Unexpected!
862 echo FAILED Unexpected second line
864 rem FIXME can't test wildcard expansion here since it's listed in directory
865 rem order, and not in alphabetic order.
866 rem Proper testing would need a currently missing "sort" program implementation.
867 rem for /d %%i in (ba*) do echo %%i>> tmp
870 rem for /d %%i in (?a*) do echo %%i>> tmp
873 rem for /d %%i in (*) do echo %%i>> tmp
881 call :WriteLine set WINE_found=N
882 for /l %%i in (1,1,%WINE_expectedresults%) do (
883 call :WriteLine if "%%%%WINE_expectedresults.%%i%%%%"=="%%%%1" set WINE_found=Y
884 call :WriteLine if "%%%%WINE_found%%%%"=="Y" set WINE_expectedresults.%%i=
885 call :WriteLine if "%%%%WINE_found%%%%"=="Y" goto :eof
887 call :WriteLine echo Got unexpected result: "%%%%1"
896 for /l %%i in (1,1,%WINE_expectedresults%) do (
897 call :WriteLine if not "%%%%WINE_expectedresults.%%i%%%%"=="" echo Found missing result: "%%%%WINE_expectedresults.%%i%%%%"
904 rem %CD% does not tork on NT4 so use the following workaround
905 for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
908 echo Plain directory enumeration
909 set WINE_expectedresults=4
910 set WINE_expectedresults.1=%WINE_CURDIR%\.
911 set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
912 set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
913 set WINE_expectedresults.4=%WINE_CURDIR%\foo\.
915 for /R %%i in (.) do call temp.bat %%i
916 call :ValidateExpected
918 echo Plain directory enumeration from provided root
919 set WINE_expectedresults=4
920 set WINE_expectedresults.1=%WINE_CURDIR%\.
921 set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
922 set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
923 set WINE_expectedresults.4=%WINE_CURDIR%\foo\.
924 if "%CD%"=="" goto :SkipBrokenNT4
926 for /R "%WINE_CURDIR%" %%i in (.) do call temp.bat %%i
927 call :ValidateExpected
930 echo File enumeration
931 set WINE_expectedresults=2
932 set WINE_expectedresults.1=%WINE_CURDIR%\baz\bazbaz
933 set WINE_expectedresults.2=%WINE_CURDIR%\bazbaz
935 for /R %%i in (baz*) do call temp.bat %%i
936 call :ValidateExpected
938 echo File enumeration from provided root
939 set WINE_expectedresults=2
940 set WINE_expectedresults.1=%WINE_CURDIR%\baz\bazbaz
941 set WINE_expectedresults.2=%WINE_CURDIR%\bazbaz
943 for /R %%i in (baz*) do call temp.bat %%i
944 call :ValidateExpected
946 echo Mixed enumeration
947 set WINE_expectedresults=6
948 set WINE_expectedresults.1=%WINE_CURDIR%\.
949 set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
950 set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
951 set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz
952 set WINE_expectedresults.5=%WINE_CURDIR%\bazbaz
953 set WINE_expectedresults.6=%WINE_CURDIR%\foo\.
955 for /R %%i in (. baz*) do call temp.bat %%i
956 call :ValidateExpected
958 echo Mixed enumeration from provided root
959 set WINE_expectedresults=6
960 set WINE_expectedresults.1=%WINE_CURDIR%\.
961 set WINE_expectedresults.2=%WINE_CURDIR%\bar\.
962 set WINE_expectedresults.3=%WINE_CURDIR%\baz\.
963 set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz
964 set WINE_expectedresults.5=%WINE_CURDIR%\bazbaz
965 set WINE_expectedresults.6=%WINE_CURDIR%\foo\.
967 for /R %%i in (. baz*) do call temp.bat %%i
968 call :ValidateExpected
970 echo With duplicates enumeration
971 set WINE_expectedresults=12
972 set WINE_expectedresults.1=%WINE_CURDIR%\bar\bazbaz
973 set WINE_expectedresults.2=%WINE_CURDIR%\bar\fred
974 set WINE_expectedresults.3=%WINE_CURDIR%\baz\bazbaz
975 set WINE_expectedresults.4=%WINE_CURDIR%\baz\bazbaz
976 set WINE_expectedresults.5=%WINE_CURDIR%\baz\bazbaz
977 set WINE_expectedresults.6=%WINE_CURDIR%\baz\fred
978 set WINE_expectedresults.7=%WINE_CURDIR%\bazbaz
979 set WINE_expectedresults.8=%WINE_CURDIR%\bazbaz
980 set WINE_expectedresults.9=%WINE_CURDIR%\bazbaz
981 set WINE_expectedresults.10=%WINE_CURDIR%\foo\bazbaz
982 set WINE_expectedresults.11=%WINE_CURDIR%\foo\fred
983 set WINE_expectedresults.12=%WINE_CURDIR%\fred
985 for /R %%i in (baz* bazbaz fred ba*) do call temp.bat %%i
986 call :ValidateExpected
988 echo Strip missing wildcards, keep unwildcarded names
989 set WINE_expectedresults=6
990 set WINE_expectedresults.1=%WINE_CURDIR%\bar\jim
991 set WINE_expectedresults.2=%WINE_CURDIR%\baz\bazbaz
992 set WINE_expectedresults.3=%WINE_CURDIR%\baz\jim
993 set WINE_expectedresults.4=%WINE_CURDIR%\bazbaz
994 set WINE_expectedresults.5=%WINE_CURDIR%\foo\jim
995 set WINE_expectedresults.6=%WINE_CURDIR%\jim
997 for /R %%i in (baz* fred* jim) do call temp.bat %%i
998 call :ValidateExpected
1001 cd .. & rd /s/Q foobar
1003 rem Some cases loop forever writing 0s, like e.g. (1,0,1), (1,a,3) or (a,b,c); those can't be tested here
1004 for /L %%i in (1,2,0) do echo %%i
1005 for@tab@/L %%i in (1,2,0) do echo %%i
1006 for /L %%i in (1,2,6) do echo %%i
1007 for /l %%i in (1 ,2,6) do echo %%i
1008 for /L %%i in (a,2,3) do echo %%i
1009 for /L %%i in (1,2,-1) do echo %%i
1010 for /L %%i in (-4,-1,-1) do echo %%i
1011 for /L %%i in (1,-2,-2) do echo %%i
1012 for /L %%i in (1,2,a) do echo %%i
1013 echo ErrorLevel %ErrorLevel%
1014 for /L %%i in (1,a,b) do echo %%i
1015 echo ErrorLevel %ErrorLevel%
1017 for /l %%i in (1,1,4) do echo %%i
1018 for /l %%i in (1,2,4) do echo %%i
1019 for /l %%i in (4,-1,1) do echo %%i
1020 for /l %%i in (4,-2,1) do echo %%i
1021 for /l %%i in (1,-1,4) do echo %%i
1022 for /l %%i in (4,1,1) do echo %%i
1023 for /L %%i in (a,2,b) do echo %%i
1024 for /L %%i in (1,1,1) do echo %%i
1025 for /L %%i in (1,-2,-1) do echo %%i
1026 for /L %%i in (-1,-1,-1) do echo %%i
1027 for /L %%i in (1,2, 3) do echo %%i
1028 rem Test zero iteration skips the body of the for
1029 for /L %%i in (2,2,1) do (
1034 rem No output when using "set expr" syntax, unless in interactive mode
1035 rem Need to use "set envvar=expr" to use in a batch script
1036 echo ------ individual operations
1038 set /a WINE_var=1 +2 & echo %WINE_var%
1039 set /a WINE_var=1 +-2 & echo %WINE_var%
1040 set /a WINE_var=1 --2 & echo %WINE_var%
1041 set /a WINE_var=2* 3 & echo %WINE_var%
1042 set /a WINE_var=-2* -5 & echo %WINE_var%
1043 set /a WINE_var=12/3 & echo %WINE_var%
1044 set /a WINE_var=13/3 & echo %WINE_var%
1045 set /a WINE_var=-13/3 & echo %WINE_var%
1046 rem FIXME Divide by zero should return an error, but error messages cannot be tested with current infrastructure
1047 set /a WINE_var=5 %% 5 & echo %WINE_var%
1048 set /a WINE_var=5 %% 3 & echo %WINE_var%
1049 set /a WINE_var=5 %% -3 & echo %WINE_var%
1050 set /a WINE_var=-5 %% -3 & echo %WINE_var%
1051 set /a WINE_var=1 ^<^< 0 & echo %WINE_var%
1052 set /a WINE_var=1 ^<^< 2 & echo %WINE_var%
1053 set /a WINE_var=1 ^<^< -2 & echo %WINE_var%
1054 set /a WINE_var=-1 ^<^< -2 & echo %WINE_var%
1055 set /a WINE_var=-1 ^<^< 2 & echo %WINE_var%
1056 set /a WINE_var=9 ^>^> 0 & echo %WINE_var%
1057 set /a WINE_var=9 ^>^> 2 & echo %WINE_var%
1058 set /a WINE_var=9 ^>^> -2 & echo %WINE_var%
1059 set /a WINE_var=-9 ^>^> -2 & echo %WINE_var%
1060 set /a WINE_var=-9 ^>^> 2 & echo %WINE_var%
1061 set /a WINE_var=5 ^& 0 & echo %WINE_var%
1062 set /a WINE_var=5 ^& 1 & echo %WINE_var%
1063 set /a WINE_var=5 ^& 3 & echo %WINE_var%
1064 set /a WINE_var=5 ^& 4 & echo %WINE_var%
1065 set /a WINE_var=5 ^& 1 & echo %WINE_var%
1066 set /a WINE_var=5 ^| 0 & echo %WINE_var%
1067 set /a WINE_var=5 ^| 1 & echo %WINE_var%
1068 set /a WINE_var=5 ^| 3 & echo %WINE_var%
1069 set /a WINE_var=5 ^| 4 & echo %WINE_var%
1070 set /a WINE_var=5 ^| 1 & echo %WINE_var%
1071 set /a WINE_var=5 ^^ 0 & echo %WINE_var%
1072 set /a WINE_var=5 ^^ 1 & echo %WINE_var%
1073 set /a WINE_var=5 ^^ 3 & echo %WINE_var%
1074 set /a WINE_var=5 ^^ 4 & echo %WINE_var%
1075 set /a WINE_var=5 ^^ 1 & echo %WINE_var%
1076 echo ------ precedence and grouping
1077 set /a WINE_var=4 + 2*3 & echo %WINE_var%
1078 set /a WINE_var=(4+2)*3 & echo %WINE_var%
1079 set /a WINE_var=4 * 3/5 & echo %WINE_var%
1080 set /a WINE_var=(4 * 3)/5 & echo %WINE_var%
1081 set /a WINE_var=4 * 5 %% 4 & echo %WINE_var%
1082 set /a WINE_var=4 * (5 %% 4) & echo %WINE_var%
1083 set /a WINE_var=3 %% (5 + 8 %% 3 ^^ 2) & echo %WINE_var%
1084 set /a WINE_var=3 %% (5 + 8 %% 3 ^^ -2) & echo %WINE_var%
1085 echo ------ octal and hexadecimal
1086 set /a WINE_var=0xf + 3 & echo %WINE_var%
1087 set /a WINE_var=0xF + 3 & echo %WINE_var%
1088 set /a WINE_var=015 + 2 & echo %WINE_var%
1089 set /a WINE_var=3, 8+3,0 & echo %WINE_var%
1090 echo ------ variables
1091 set /a WINE_var=WINE_foo=3, WINE_foo+1 & echo %WINE_var%
1092 if defined WINE_foo (echo %WINE_foo%) else (
1093 echo WINE_foo not defined
1095 set /a WINE_var=WINE_foo=3, WINE_foo+=1 & echo %WINE_var%
1096 set /a WINE_var=WINE_foo=3, WINE_bar=1, WINE_bar+=WINE_foo, WINE_bar & echo %WINE_var%
1097 set /a WINE_var=WINE_foo*= WINE_foo & echo %WINE_var%
1098 set /a WINE_var=WINE_whateverNonExistingVar & echo %WINE_var%
1099 set /a WINE_var=WINE_whateverNonExistingVar + WINE_bar & echo %WINE_var%
1100 set /a WINE_var=WINE_foo -= WINE_foo + 7 & echo %WINE_var%
1101 set /a WINE_var=WINE_foo /= 3 + 2 & echo %WINE_var%
1102 set /a WINE_var=WINE_foo=5, WINE_foo %%=2 & echo %WINE_var%
1103 set /a WINE_var=WINE_foo ^<^<= 2 & echo %WINE_var%
1104 set /a WINE_var=WINE_foo ^>^>= 2 & echo %WINE_var%
1105 set /a WINE_var=WINE_foo ^&= 2 & echo %WINE_var%
1106 set /a WINE_var=WINE_foo=5, WINE_foo ^|= 2 & echo %WINE_var%
1107 set /a WINE_var=WINE_foo=5, WINE_foo ^^= 2 & echo %WINE_var%
1108 set /a WINE_var=WINE_foo=19, WINE_foo %%= 4 + (WINE_bar %%= 7) & echo.
1113 mkdir foobar & cd foobar
1114 echo ------ string argument
1115 rem NT4 does not support usebackq
1116 for /F %%i in ("a b c") do echo %%i
1117 for /f usebackq %%i in ('a b c') do echo %%i>output_file
1118 if not exist output_file (echo no output) else (type output_file & del output_file)
1119 for /f %%i in ("a ") do echo %%i
1120 for /f usebackq %%i in ('a ') do echo %%i>output_file
1121 if not exist output_file (echo no output) else (type output_file & del output_file)
1122 for /f %%i in ("a") do echo %%i
1123 for /f usebackq %%i in ('a') do echo %%i>output_file
1124 if not exist output_file (echo no output) else (type output_file & del output_file)
1125 fOr /f %%i in (" a") do echo %%i
1126 for /f usebackq %%i in (' a') do echo %%i>output_file
1127 if not exist output_file (echo no output) else (type output_file & del output_file)
1128 for /f %%i in (" a ") do echo %%i
1129 for /f usebackq %%i in (' a ') do echo %%i>output_file
1130 if not exist output_file (echo no output) else (type output_file & del output_file)
1131 echo ------ fileset argument
1132 echo --------- basic blank handling
1134 for /f %%i in (foo) do echo %%i
1136 for /f %%i in (foo) do echo %%i
1138 for /f %%i in (foo) do echo %%i
1140 for /f %%i in (foo) do echo %%i
1142 for /f %%i in (foo) do echo %%i
1144 for /f %%i in (foo) do echo %%i
1147 for /f %%i in (foo) do echo %%i
1148 echo --------- multi-line with empty lines
1155 for /f %%b in (foo) do echo %%b
1156 echo --------- multiple files
1160 for /f %%k in (foo bar) do echo %%k
1161 for /f %%k in (bar foo) do echo %%k
1162 echo ------ command argument
1163 rem Not implemented on NT4, need to skip it as no way to get output otherwise
1164 if "%CD%"=="" goto :SkipFORFcmdNT4
1165 for /f %%i in ('echo.Passed1') do echo %%i
1166 for /f "usebackq" %%i in (`echo.Passed2`) do echo %%i
1167 for /f usebackq %%i in (`echo.Passed3`) do echo %%i
1170 for /l %%i in (1,1,3) do echo Missing functionality - Broken%%i
1172 rem FIXME: Rest not testable right now in wine: not implemented and would need
1173 rem preliminary grep-like program implementation (e.g. like findstr or fc) even
1174 rem for a simple todo_wine test
1175 rem (for /f "usebackq" %%i in (`echo z a b`) do echo %%i) || echo not supported
1176 rem (for /f usebackq %%i in (`echo z a b`) do echo %%i) || echo not supported
1177 echo ------ eol option
1178 if "%CD%"=="" goto :SkipFORFeolNT4
1180 echo and Line two>>foo
1181 echo Line three>>foo
1182 for /f "eol=L" %%i in (foo) do echo %%i
1183 for /f "eol=a" %%i in (foo) do echo %%i
1185 goto :ContinueFORFeol
1187 for /l %%i in (1,1,3) do echo Broken NT4 functionality%%i
1189 for /f "eol=@" %%i in (" ad") do echo %%i
1190 for /f "eol=@" %%i in (" z@y") do echo %%i
1191 for /f "eol=|" %%i in ("a|d") do echo %%i
1192 for /f "eol=@" %%i in ("@y") do echo %%i > output_file
1193 if not exist output_file (echo no output) else (del output_file)
1194 for /f "eol==" %%i in ("=y") do echo %%i > output_file
1195 if not exist output_file (echo no output) else (del output_file)
1196 echo ------ delims option
1197 for /f "delims=|" %%i in ("a|d") do echo %%i
1198 for /f "delims=|" %%i in ("a |d") do echo %%i
1199 for /f "delims=|" %%i in ("a d|") do echo %%i
1200 for /f "delims=| " %%i in ("a d|") do echo %%i
1201 for /f "delims==" %%i in ("C r=d|") do echo %%i
1202 for /f "delims=" %%i in ("foo bar baz") do echo %%i
1203 for /f "delims=" %%i in ("c:\foo bar baz\..") do echo %%~fi
1204 echo ------ skip option
1208 for /f "skip=2" %%i in (foo) do echo %%i
1209 for /f "skip=3" %%i in (foo) do echo %%i > output_file
1210 if not exist output_file (echo no output) else (del output_file)
1211 for /f "skip=4" %%i in (foo) do echo %%i > output_file
1212 if not exist output_file (echo no output) else (del output_file)
1213 for /f "skip=02" %%i in (foo) do echo %%i
1214 for /f "skip=0x2" %%i in (foo) do echo %%i
1215 for /f "skip=1" %%i in ("skipme") do echo %%i > output_file
1216 if not exist output_file (echo no output) else (del output_file)
1217 echo ------ tokens= option
1219 for /f %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1220 for /f "tokens=2" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1221 for /f "tokens=1,3,5-7" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1222 rem Show * means the rest
1223 for /f "tokens=1,5*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1224 for /f "tokens=6,9*" %%i in ("a b c d e f g h i j k l m n o p q r s t u v w x y z") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1225 rem Show * means the rest (not tokenized and rebuilt)
1226 for /f "tokens=6,9*" %%i in ("a b c d e f g h i j k l m n;;== o p q r s t u v w x y z") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1227 rem Order is irrelevant
1228 for /f "tokens=1,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1229 for /f "tokens=3,2,1*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1230 rem Duplicates are ignored
1231 for /f "tokens=1,2,1*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1232 rem Large tokens are allowed
1233 for /f "tokens=25,1,5*" %%i in ("a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1234 rem Show tokens blanked in advance regardless of uniqueness of requested tokens
1235 for /f "tokens=1,1,1,2*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1236 for /f "tokens=1-2,1-2,1-2" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1237 rem Show No wrapping from z to A BUT wrapping sort of occurs Z to a occurs
1238 for /f "tokens=1-20" %%u in ("a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") do echo u=%%u v=%%v w=%%w x=%%x y=%%y z=%%z A=%%A a=%%a
1239 for /f "tokens=1-20" %%U in ("a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z") do echo U=%%U V=%%V W=%%W X=%%X Y=%%Y Z=%%Z A=%%A a=%%a
1240 rem Show negative ranges have no effect
1241 for /f "tokens=1-3,5" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1242 for /f "tokens=3-1,5" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m o=%%o
1243 rem Show duplicates stop * from working
1244 for /f "tokens=1,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1245 for /f "tokens=1,1,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1246 for /f "tokens=2,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1247 for /f "tokens=3,2,3*" %%i in ("a b c d e f g") do echo h=%%h i=%%i j=%%j k=%%k l=%%l m=%%m n=%%n o=%%o
1251 echo ------------ Testing del /a ------------
1252 del /f/q *.test > nul
1255 echo not-r > not-r.test
1257 if not exist not-r.test echo not-r.test not found before delete, bad
1259 if not exist not-r.test echo not-r.test not found after delete, good
1261 if not exist r.test echo r.test not found before delete, bad
1262 if exist r.test echo r.test found before delete, good
1264 if not exist r.test echo r.test not found after delete, good
1265 if exist r.test echo r.test found after delete, bad
1267 echo ------------ Testing del /q ------------
1271 echo abc > file2.dat
1272 rem If /q doesn't work, cmd will prompt and the test case should hang
1274 for %%a in (1 2.dat) do if exist file%%a echo del /q * failed on file%%a
1275 for %%a in (1 2.dat) do if not exist file%%a echo del /q * succeeded on file%%a
1279 echo ------------ Testing del /s ------------
1284 echo there > file2.dat
1285 echo bub > file3.dat
1286 echo bye > "file with spaces.dat"
1288 del /s file1.dat > nul
1289 del file2.dat /s > nul
1290 del "file3.dat" /s > nul
1291 del "file with spaces.dat" /s > nul
1293 for %%f in (1 2 3) do if exist file%%f.dat echo Del /s failed on file%%f
1294 for %%f in (1 2 3) do if exist file%%f.dat del file%%f.dat
1295 if exist "file with spaces.dat" echo Del /s failed on "file with spaces.dat"
1296 if exist "file with spaces.dat" del "file with spaces.dat"
1301 echo ------------ Testing rename ------------
1302 mkdir foobar & cd foobar
1303 echo --- ren and rename are synonymous
1306 if exist foo echo foo should be renamed!
1307 if exist bar echo foo renamed to bar
1309 if exist bar echo bar should be renamed!
1310 if exist foo echo bar renamed to foo
1311 echo --- name collision
1321 echo --- rename read-only files
1325 if not exist file1 (
1327 echo read-only file renamed
1330 echo read-only file not renamed!
1332 echo --- rename directories
1344 echo read-only dir renamed
1347 echo --- rename in other directory
1348 if not exist baz\abc (
1349 echo rename impossible in other directory
1350 if exist foo echo original file still present
1352 echo shouldn't rename in other directory!
1353 if not exist foo echo original file not present anymore
1355 cd .. & rd /s/q foobar
1357 echo ------------ Testing move ------------
1358 mkdir foobar & cd foobar
1361 move foo bar > nul 2>&1
1364 echo file move succeeded
1369 move /Y bar baz > nul 2>&1
1372 echo file move with overwrite succeeded
1375 echo file overwrite impossible!
1381 move baz bazro > nul 2>&1
1384 echo read-only files are moveable
1385 move bazro baz > nul 2>&1
1388 echo read-only file not moved!
1392 move baz rep > nul 2>&1
1395 echo file moved in subdirectory
1399 move rep\baz . > nul 2>&1
1400 move /Y baz baz > nul 2>&1
1402 echo moving a file to itself should be a no-op!
1404 echo moving a file to itself is a no-op
1406 echo ErrorLevel: %ErrorLevel%
1409 echo --- directory move
1413 move baz foo\bar > nul 2>&1
1415 if exist foo\bar\baz\baz2 (
1416 echo simple directory move succeeded
1421 move baz baz > nul 2>&1
1422 echo moving a directory to itself gives error; errlevel %ErrorLevel%
1423 echo ------ dir in dir move
1428 move foo bar > nul 2>&1
1436 cd .. & rd /s/q foobar
1438 echo ------------ Testing mkdir ------------
1440 echo --- md and mkdir are synonymous
1447 echo --- creating an already existing directory/file must fail
1456 echo --- multilevel path creation
1468 mkdir ..\..\..\foo\bar2
1471 mkdir ..\..\..\foo\bar2
1473 rmdir ..\..\..\foo\bar2
1481 echo --- trailing backslashes
1484 if exist foo (rmdir foo & echo dir created
1485 ) else ( echo dir not created )
1487 echo --- invalid chars
1489 echo mkdir ? gives errorlevel %ErrorLevel%
1492 echo mkdir ?\foo gives errorlevel %ErrorLevel%
1495 echo mkdir foo\? gives errorlevel %ErrorLevel%
1496 if exist foo (rmdir foo & echo ok, foo created
1497 ) else ( echo foo not created )
1500 echo mkdir foo\bar\? gives errorlevel %ErrorLevel%
1503 echo bad, foo not created
1507 echo ok, foo\bar created
1513 echo --- multiple directories at once
1514 mkdir foobaz & cd foobaz
1515 mkdir foo bar\baz foobar "bazbaz" .\"zabzab"
1516 if exist foo (echo foo created) else echo foo not created!
1517 if exist bar (echo bar created) else echo bar not created!
1518 if exist foobar (echo foobar created) else echo foobar not created!
1519 if exist bar\baz (echo bar\baz created) else echo bar\baz not created!
1520 if exist bazbaz (echo bazbaz created) else echo bazbaz not created!
1521 if exist zabzab (echo zabzab created) else echo zabzab not created!
1522 cd .. & rd /s/q foobaz
1525 echo mkdir foo\* errorlevel %ErrorLevel%
1526 if exist foo (rmdir foo & echo ok, foo created
1527 ) else ( echo bad, foo not created )
1529 echo ------------ Testing rmdir ------------
1531 rem rd and rmdir are synonymous
1535 if not exist foobar echo dir removed
1539 if not exist foobar echo dir removed
1540 rem Removing nonexistent directory
1543 rem Removing single-level directories
1547 if exist foo echo file not removed
1553 if exist foo echo non-empty dir not removed
1558 if exist foo echo non-empty dir not removed
1565 echo recursive rmdir succeeded
1572 echo foo > foo\bar\brol
1573 rmdir /s /Q foo 2>&1
1575 echo recursive rmdir succeeded
1582 rem multiples directories at once
1583 mkdir foobaz & cd foobaz
1587 rd /s/q foo bar foobar
1588 if not exist foo (echo foo removed) else echo foo not removed!
1589 if not exist bar (echo bar removed) else echo bar not removed!
1590 if not exist foobar (echo foobar removed) else echo foobar not removed!
1591 if not exist bar\baz (echo bar\baz removed) else echo bar\baz not removed!
1592 cd .. & rd /s/q foobaz
1594 echo ------------ Testing pushd/popd ------------
1596 echo --- popd is no-op when dir stack is empty
1599 echo --- pushing non-existing dir
1602 echo --- basic behaviour
1627 echo ------------ Testing attrib ------------
1628 rem FIXME Add tests for archive, hidden and system attributes + mixed attributes modifications
1629 mkdir foobar & cd foobar
1630 echo foo original contents> foo
1633 echo --- read-only attribute
1634 rem Read-only files cannot be altered or deleted, unless forced
1642 echo Read-only file not deleted
1644 echo Should not delete read-only file!
1648 echo Read-only file forcibly deleted
1650 echo Should delete read-only file with del /F!
1654 cd .. & rd /s/q foobar
1655 echo --- recursive behaviour
1656 mkdir foobar\baz & cd foobar
1662 attrib +R l*vel? /S > nul 2>&1
1668 cd .. & rd /s/q foobar
1669 echo --- folders processing
1675 attrib +r baz /s /d > nul 2>&1
1681 rem Oddly windows allows file creation in a read-only directory...
1682 if exist baz\lala (echo file created in read-only dir) else echo file not created
1683 cd .. & rd /s/q foobar
1685 echo ------------ Testing assoc ------------
1686 rem FIXME Can't test error messages in the current test system, so we have to use some kludges
1687 rem FIXME Revise once || conditional execution is fixed
1688 mkdir foobar & cd foobar
1689 echo --- setting association
1697 rem association set system-wide
1698 echo @echo off> tmp.cmd
1699 echo echo +++>> tmp.cmd
1700 echo assoc .foo>> tmp.cmd
1703 echo --- resetting association
1709 rem association removal set system-wide
1710 cmd /c tmp.cmd > baz
1713 cd .. & rd /s/q foobar
1715 echo ------------ Testing ftype ------------
1716 rem FIXME Can't test error messages in the current test system, so we have to use some kludges
1717 rem FIXME Revise once || conditional execution is fixed
1718 mkdir foobar & cd foobar
1719 echo --- setting association
1724 ftype footype=foo_opencmd
1728 rem association set system-wide
1729 echo @echo off> tmp.cmd
1730 echo echo +++>> tmp.cmd
1731 echo ftype footype>> tmp.cmd
1734 echo --- resetting association
1737 rem Removing a file type association doesn't work on XP due to a bug, so a workaround is needed
1738 setlocal EnableDelayedExpansion
1739 set WINE_FOO=original value
1742 for /F %%i in ('type baz') do (set WINE_FOO=buggyXP)
1743 rem Resetting actually works on wine/NT4, but is reported as failing due to the peculiar test (and non-support for EnabledDelayedExpansion)
1744 rem FIXME Revisit once a grep-like program like ftype is implemented
1745 rem (e.g. to check baz's size using dir /b instead)
1748 rem cleanup registry
1749 echo REGEDIT4> regCleanup.reg
1750 echo.>> regCleanup.reg
1751 echo [-HKEY_CLASSES_ROOT\footype]>> regCleanup.reg
1752 regedit /s regCleanup.reg
1755 cd .. & rd /s/q foobar
1757 echo ------------ Testing CALL ------------
1758 mkdir foobar & cd foobar
1759 echo --- external script
1760 echo echo foo %%1> foo.cmd
1763 echo echo %%1 %%2 > foo.cmd
1765 call foo.cmd foo bar
1772 echo --- internal routines
1773 call :testRoutine :testRoutine
1774 goto :endTestRoutine
1780 call :testRoutineArgs foo
1781 call :testRoutineArgs foo bar
1782 call :testRoutineArgs foo ""
1783 call :testRoutineArgs "" bar
1784 call :testRoutineArgs foo ''
1785 call :testRoutineArgs '' bar
1786 goto :endTestRoutineArgs
1792 echo --- with builtins
1795 if exist foo (echo foo created) else echo foo should exist!
1797 set WINE_FOOBAZ_VAR=foobaz
1798 call echo Should expand %WINE_FOOBAZ_VAR%
1799 set WINE_FOOBAZ_VAR=
1803 if 1==1 call del batfile
1805 if exist batfile echo batfile shouldn't exist
1806 rem ... but not for 'if' or 'for'
1807 call if 1==1 echo bar 2> nul
1810 call for %%i in (foo bar baz) do echo %%i 2> nul
1812 rem First look for programs in the path before trying a builtin
1813 echo echo non-builtin dir> dir.cmd
1816 rem The below line equates to call (, which does nothing, then the
1817 rem subsequent lines are executed.
1822 rem The below line equates to call if, which always fails, then the
1823 rem subsequent lines are executed. Note cmd.exe swallows all lines
1830 call call call echo passed
1831 cd .. & rd /s/q foobar
1833 echo ------------ Testing SHIFT ------------
1835 call :shiftFun p1 p2 p3 p4 p5
1839 echo '%1' '%2' '%3' '%4' '%5'
1841 echo '%1' '%2' '%3' '%4' '%5'
1843 echo '%1' '%2' '%3' '%4' '%5'
1845 echo '%1' '%2' '%3' '%4' '%5'
1847 echo '%1' '%2' '%3' '%4' '%5'
1849 echo '%1' '%2' '%3' '%4' '%5'
1853 echo ------------ Testing cmd invocation ------------
1854 rem FIXME: only a stub ATM
1855 echo --- a batch file can delete itself
1856 echo del foo.cmd>foo.cmd
1858 if not exist foo.cmd (
1859 echo file correctly deleted
1861 echo file should be deleted!
1864 echo --- a batch file can alter itself
1865 echo echo bar^>foo.cmd>foo.cmd
1866 cmd /q /c foo.cmd > NUL 2>&1
1871 echo file not created!
1874 echo ---------- Testing copy
1877 rem Note echo adds 0x0d 0x0a on the end of the line in the file
1880 echo CCCCCCCCC> file3
1886 echo Passed: Found expected %1
1888 echo Failed: Did not find expected %1
1890 del /q "%1" >nul 2>&1
1892 if not "%1"=="" goto :CheckExist
1897 echo Passed: Did not find %1
1899 echo Failed: Unexpectedly found %1
1900 del /q "%1" >nul 2>&1
1903 if not "%1"=="" goto :CheckNotExist
1906 rem Note: No way to check file size on NT4 so skip the test
1909 echo Failed: File missing when requested filesize check [%2]
1910 goto :ContinueFileSizeChecks
1912 for %%i in (%1) do set WINE_filesize=%%~zi
1913 if "%WINE_filesize%"=="%2" (
1914 echo Passed: file size check on %1 [%WINE_filesize%]
1916 if "%WINE_filesize%"=="%%~zi" (
1917 echo Skipping file size check on NT4
1919 echo Failed: file size check on %1 [%WINE_filesize% != %2]
1922 :ContinueFileSizeChecks
1925 if not "%1"=="" goto :CheckFileSize
1930 rem -----------------------
1931 rem Simple single file copy
1932 rem -----------------------
1933 rem Simple single file copy, normally used syntax
1934 copy file1 dummy.file >nul 2>&1
1935 if errorlevel 1 echo Incorrect errorlevel
1936 call :CheckExist dummy.file
1938 rem Simple single file copy, destination supplied as two forms of directory
1939 copy file1 dir1 >nul 2>&1
1940 if errorlevel 1 echo Incorrect errorlevel
1941 call :CheckExist dir1\file1
1943 copy file1 dir1\ >nul 2>&1
1944 if errorlevel 1 echo Incorrect errorlevel
1945 call :CheckExist dir1\file1
1947 rem Simple single file copy, destination supplied as fully qualified destination
1948 copy file1 dir1\file99 >nul 2>&1
1949 if errorlevel 1 echo Incorrect errorlevel
1950 call :CheckExist dir1\file99
1952 rem Simple single file copy, destination not supplied
1954 copy ..\file1 >nul 2>&1
1955 if errorlevel 1 echo Incorrect errorlevel
1956 call :CheckExist file1
1959 rem Simple single file copy, destination supplied as nonexistent directory
1960 copy file1 dir2\ >nul 2>&1
1961 if not errorlevel 1 echo Incorrect errorlevel
1962 call :CheckNotExist dir2 dir2\file1
1964 rem -----------------------
1966 rem -----------------------
1967 rem Simple single file copy, destination supplied as two forms of directory
1968 copy file? dir1 >nul 2>&1
1969 if errorlevel 1 echo Incorrect errorlevel
1970 call :CheckExist dir1\file1 dir1\file2 dir1\file3
1972 copy file* dir1\ >nul 2>&1
1973 if errorlevel 1 echo Incorrect errorlevel
1974 call :CheckExist dir1\file1 dir1\file2 dir1\file3
1976 rem Simple single file copy, destination not supplied
1978 copy ..\file*.* >nul 2>&1
1979 if errorlevel 1 echo Incorrect errorlevel
1980 call :CheckExist file1 file2 file3
1983 rem Simple wildcarded file copy, destination supplied as nonexistent directory
1984 copy file? dir2\ >nul 2>&1
1985 if not errorlevel 1 echo Incorrect errorlevel
1986 call :CheckNotExist dir2 dir2\file1 dir2\file2 dir2\file3
1988 rem ------------------------------------------------
1989 rem Confirm overwrite works (cannot test prompting!)
1990 rem ------------------------------------------------
1991 copy file1 testfile >nul 2>&1
1992 copy /y file2 testfile >nul 2>&1
1993 call :CheckExist testfile
1995 rem ------------------------------------------------
1996 rem Test concatenation
1997 rem ------------------------------------------------
1998 rem simple case, no wildcards
1999 copy file1+file2 testfile >nul 2>&1
2000 if errorlevel 1 echo Incorrect errorlevel
2001 call :CheckExist testfile
2003 rem simple case, wildcards, no concatenation
2004 copy file* testfile >nul 2>&1
2005 if errorlevel 1 echo Incorrect errorlevel
2006 call :CheckExist testfile
2008 rem simple case, wildcards, and concatenation
2010 copy file*+fred testfile >nul 2>&1
2011 if errorlevel 1 echo Incorrect errorlevel
2012 call :CheckExist testfile
2014 rem simple case, wildcards, and concatenation
2015 copy fred+file* testfile >nul 2>&1
2016 if errorlevel 1 echo Incorrect errorlevel
2017 call :CheckExist testfile
2019 rem Calculate destination name
2020 copy fred+file* dir1 >nul 2>&1
2021 if errorlevel 1 echo Incorrect errorlevel
2022 call :CheckExist dir1\fred
2024 rem Calculate destination name
2025 copy fred+file* dir1\ >nul 2>&1
2026 if errorlevel 1 echo Incorrect errorlevel
2027 call :CheckExist dir1\fred
2029 rem Calculate destination name (none supplied)
2031 copy ..\fred+..\file* >nul 2>&1
2032 if errorlevel 1 echo Incorrect errorlevel
2033 call :CheckExist fred
2035 copy ..\fr*+..\file1 >nul 2>&1
2036 if errorlevel 1 echo Incorrect errorlevel
2037 call :CheckExist fred
2040 rem ******************************************************************
2041 rem ASCII and BINARY tests
2042 rem Note: hard coded numbers deliberate because need to ensure whether
2043 rem an additional EOF has been added or not. There is no way to handle
2044 rem EOFs in batch, so assume if a single byte appears, its an EOF!
2045 rem ******************************************************************
2047 rem Confirm original sizes of file1,2,3
2048 call :CheckFileSize file1 5 file2 8 file3 11
2052 rem ----------------------------------------------
2053 rem Show concatenation defaults copy to ascii mode
2054 rem ----------------------------------------------
2055 rem Simple default copy source to destination (should not append EOF 5)
2056 copy ..\file1 file1_default >nul 2>&1
2057 call :CheckFileSize file1_default 5
2059 rem Simple binary copy source to destination (should not append EOF 5)
2060 copy /b ..\file1 file1_default2 >nul 2>&1
2061 call :CheckFileSize file1_default2 5
2063 rem Simple ascii copy source to destination (should append EOF 5+1, 8+1, 11+1)
2064 copy /a ..\file1 file1_plus_eof >nul 2>&1
2065 call :CheckFileSize file1_plus_eof 6
2066 copy /a ..\file2 file2_plus_eof >nul 2>&1
2067 call :CheckFileSize file2_plus_eof 9
2068 copy /a ..\file3 file3_plus_eof >nul 2>&1
2069 call :CheckFileSize file3_plus_eof 12
2071 rem Concat 2 files, ascii mode - (only one EOF on the end 5+8+1)
2072 copy /a ..\file1+..\file2 file12_plus_eof >nul 2>&1
2073 call :CheckFileSize file12_plus_eof 14
2075 rem Concat 2 files, binary mode - (no EOF on the end 5+8)
2076 copy /b ..\file1+..\file2 file12_no_eof >nul 2>&1
2077 call :CheckFileSize file12_no_eof 13
2079 rem Concat 2 files, default mode - (one EOF on the end 5+8+1)
2080 copy ..\file1+..\file2 file12_eof2 >nul 2>&1
2081 call :CheckFileSize file12_eof2 14
2083 rem --------------------------------------------------------------
2084 rem Show ascii source copy stops at first EOF, binary does the lot
2085 rem --------------------------------------------------------------
2086 copy file1_plus_eof /b file1_binary_srccopy /b >nul 2>&1
2087 call :CheckFileSize file1_binary_srccopy 6
2089 copy file1_plus_eof /a file1_ascii_srccopy /b >nul 2>&1
2090 call :CheckFileSize file1_ascii_srccopy 5
2092 rem --------------------------------------------------------------
2093 rem Show results of concatenating files (ending in EOFs) and /a /b
2094 rem --------------------------------------------------------------
2096 rem Default and ascii copy reads as ascii, stripping EOFs, so 6-1 + 9-1 + 12-1 + 1
2097 copy file1_plus_eof+file2_plus_eof+file3_plus_eof file123_default_copy >nul 2>&1
2098 call :CheckFileSize file123_default_copy 25
2099 copy /a file1_plus_eof+file2_plus_eof+file3_plus_eof file123_ascii_copy >nul 2>&1
2100 call :CheckFileSize file123_ascii_copy 25
2102 rem In binary mode, we get 3 eofs, so 6 + 9 + 12 = 27
2103 copy /b file1_plus_eof + file2_plus_eof + file3_plus_eof file123_binary_copy >nul 2>&1
2104 call :CheckFileSize file123_binary_copy 27
2106 rem We can select which we want the eofs from by postfixing it with /a or /b
2107 rem so here have first and third with eof, second as ascii 6 + 9-1 + 12
2108 copy file1_plus_eof /b + file2_plus_eof /a + file3_plus_eof /b file123_mixed_copy1 >nul 2>&1
2109 call :CheckFileSize file123_mixed_copy1 26
2111 rem By postfixing the destination with /a, we ask for an ascii destination which appends EOF
2112 rem so here have first and third with eof, second as ascii 6 + 9-1 + 12 + extra EOF
2113 rem Note the delta between this and the previous one also shows that the destination
2114 rem ascii/binary is inherited from the last /a or /b on the line
2115 copy file1_plus_eof /b + file2_plus_eof /a + file3_plus_eof /b file123_mixed_copy2 /a >nul 2>&1
2116 call :CheckFileSize file123_mixed_copy2 27
2118 rem so here have second with eof, first and third as ascii 6-1 + 9 + 12-1
2119 rem Note the delta between the next two also shows that the destination ascii/binary is
2120 rem inherited from the last /a or /b on the line, so the first has an extra EOF
2121 copy file1_plus_eof /a + file2_plus_eof /b + file3_plus_eof /a file123_mixed_copy3 >nul 2>&1
2122 call :CheckFileSize file123_mixed_copy3 26
2123 copy file1_plus_eof /a + file2_plus_eof /b + file3_plus_eof /a file123_mixed_copy4 /b >nul 2>&1
2124 call :CheckFileSize file123_mixed_copy4 25
2126 rem -------------------------------------------------------------------------------------------
2127 rem This shows when concatenating, an ascii destination always adds on an EOF but when we
2128 rem are not concatenating, its a direct copy regardless of destination if being read as binary
2129 rem -------------------------------------------------------------------------------------------
2131 rem All 3 have eof's, plus an extra = 6 + 9 + 12 + eof
2132 copy /b file1_plus_eof + file2_plus_eof + file3_plus_eof file123_mixed_copy5 /a >nul 2>&1
2133 call :CheckFileSize file123_mixed_copy5 28
2135 rem All 2 have eof's, plus an extra = 6 + 12 + eof
2136 copy /b file1_plus_eof + file3_plus_eof file123_mixed_copy6 /a >nul 2>&1
2137 call :CheckFileSize file123_mixed_copy6 19
2139 rem One file has EOF, but doesn't get an extra one, i.e. 6
2140 copy /b file1_plus_eof file123_mixed_copy7 /a >nul 2>&1
2141 call :CheckFileSize file123_mixed_copy7 6
2143 rem Syntax means concatenate so ascii destination kicks in
2144 copy /b file1_plus_eof* file123_mixed_copy8 /a >nul 2>&1
2145 call :CheckFileSize file123_mixed_copy8 7
2150 rem ---------------------------------------
2151 rem Error combinations
2152 rem ---------------------------------------
2153 rem Specify source directory but name is a file
2155 copy file1\ dir1\ >NUL 2>&1
2156 if errorlevel 1 echo Passed: errorlevel invalid check 1
2157 if not errorlevel 1 echo Failed: errorlevel invalid check 1
2158 call :CheckNotExist dir1\file1
2160 rem Overwrite same file
2162 copy file1 file1 >NUL 2>&1
2163 if errorlevel 1 echo Passed: errorlevel invalid check 2
2164 if not errorlevel 1 echo Failed: errorlevel invalid check 2
2166 rem Supply same file identified as a directory
2168 copy file1 file1\ >NUL 2>&1
2169 if errorlevel 1 echo Passed: errorlevel invalid check 3
2170 if not errorlevel 1 echo Failed: errorlevel invalid check 3
2175 echo ------------ Testing setlocal/endlocal ------------
2177 rem Note: setlocal EnableDelayedExpansion already tested in the variable delayed expansion test section
2178 mkdir foobar & cd foobar
2179 echo --- enable/disable extensions
2180 setlocal DisableEXTensions
2181 echo ErrLev: %ErrorLevel%
2183 echo ErrLev: %ErrorLevel%
2184 echo @echo off> tmp.cmd
2185 echo echo ErrLev: %%ErrorLevel%%>> tmp.cmd
2186 rem Enabled by default
2188 cmd /E:OfF /C tmp.cmd
2189 cmd /e:oN /C tmp.cmd
2191 rem FIXME: creating file before setting envvar value to prevent parsing-time evaluation (due to EnableDelayedExpansion not being implemented/available yet)
2192 echo --- setlocal with corresponding endlocal
2193 rem %CD% does not tork on NT4 so use the following workaround
2194 for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
2195 echo @echo off> test.cmd
2196 echo echo %%WINE_VAR%%>> test.cmd
2197 echo setlocal>> test.cmd
2198 echo set WINE_VAR=localval>> test.cmd
2199 echo md foobar2>> test.cmd
2200 echo cd foobar2>> test.cmd
2201 echo echo %%WINE_VAR%%>> test.cmd
2202 echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd
2203 echo endlocal>> test.cmd
2204 echo echo %%WINE_VAR%%>> test.cmd
2205 echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd
2206 set WINE_VAR=globalval
2209 for /d %%i in (.) do echo %%~dpnxi
2213 echo --- setlocal with no corresponding endlocal
2214 echo @echo off> test.cmd
2215 echo echo %%WINE_VAR%%>> test.cmd
2216 echo setlocal>> test.cmd
2217 echo set WINE_VAR=localval>> test.cmd
2218 echo md foobar2>> test.cmd
2219 echo cd foobar2>> test.cmd
2220 echo echo %%WINE_VAR%%>> test.cmd
2221 echo for /d %%%%i in (.) do echo %%%%~dpnxi>> test.cmd
2222 set WINE_VAR=globalval
2223 rem %CD% does not tork on NT4 so use the following workaround
2224 for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
2227 for /d %%i in (.) do echo %%~dpnxi
2231 echo --- setlocal within same batch program
2235 rem %CD% does not tork on NT4 so use the following workaround
2236 for /d %%i in (.) do set WINE_CURDIR=%%~dpnxi
2243 if "%WINE_var1%"=="one" echo Var1 ok 1
2244 if "%WINE_var2%"=="two" echo Var2 ok 2
2245 if "%WINE_var3%"=="three" echo Var3 ok 3
2246 for /d %%i in (.) do set WINE_curdir2=%%~dpnxi
2247 if "%WINE_curdir2%"=="%WINE_CURDIR%\foobar2" echo Directory is ok 1
2249 if "%WINE_var1%"=="one" echo Var1 ok 1
2250 if "%WINE_var2%"=="two" echo Var2 ok 2
2251 if "%WINE_var3%"=="" echo Var3 ok 3
2252 for /d %%i in (.) do set WINE_curdir2=%%~dpnxi
2253 if "%WINE_curdir2%"=="%WINE_CURDIR%\foobar2" echo Directory is ok 2
2255 if "%WINE_var1%"=="one" echo Var1 ok 1
2256 if "%WINE_var2%"=="" echo Var2 ok 2
2257 if "%WINE_var3%"=="" echo Var3 ok 3
2258 for /d %%i in (.) do set WINE_curdir2=%%~dpnxi
2259 if "%WINE_curdir2%"=="%WINE_CURDIR%" echo Directory is ok 3
2263 echo --- Mismatched set and end locals
2267 rem %CD% does not tork on NT4 so use the following workaround
2268 for /d %%i in (.) do set WINE_curdir=%%~dpnxi
2270 echo @echo off> 2set1end.cmd
2271 echo echo %%WINE_var%%>> 2set1end.cmd
2272 echo setlocal>> 2set1end.cmd
2273 echo set WINE_VAR=2set1endvalue1>> 2set1end.cmd
2274 echo cd ..\foodir3>> 2set1end.cmd
2275 echo setlocal>> 2set1end.cmd
2276 echo set WINE_VAR=2set1endvalue2>> 2set1end.cmd
2277 echo cd ..\foodir4>> 2set1end.cmd
2278 echo endlocal>> 2set1end.cmd
2279 echo echo %%WINE_var%%>> 2set1end.cmd
2280 echo for /d %%%%i in (.) do echo %%%%~dpnxi>> 2set1end.cmd
2282 echo @echo off> 1set2end.cmd
2283 echo echo %%WINE_var%%>> 1set2end.cmd
2284 echo setlocal>> 1set2end.cmd
2285 echo set WINE_VAR=1set2endvalue1>> 1set2end.cmd
2286 echo cd ..\foodir3>> 1set2end.cmd
2287 echo endlocal>> 1set2end.cmd
2288 echo echo %%WINE_var%%>> 1set2end.cmd
2289 echo for /d %%%%i in (.) do echo %%%%~dpnxi>> 1set2end.cmd
2290 echo endlocal>> 1set2end.cmd
2291 echo echo %%WINE_var%%>> 1set2end.cmd
2292 echo for /d %%%%i in (.) do echo %%%%~dpnxi>> 1set2end.cmd
2294 echo --- Extra setlocal in called batch
2296 rem -- setlocal1 == this batch, should never be used inside a called routine
2300 call %WINE_CURDIR%\2set1end.cmd
2303 for /d %%i in (.) do echo %%~dpnxi
2306 for /d %%i in (.) do echo %%~dpnxi
2309 echo --- Extra endlocal in called batch
2311 rem -- setlocal1 == this batch, should never be used inside a called routine
2315 call %WINE_CURDIR%\1set2end.cmd
2318 for /d %%i in (.) do echo %%~dpnxi
2321 for /d %%i in (.) do echo %%~dpnxi
2324 echo --- endlocal in called function rather than batch pgm is ineffective
2330 call :endlocalroutine
2334 goto :endlocalfinished
2352 cd .. & rd /q/s foobar
2354 echo ------------ Testing Errorlevel ------------
2355 rem WARNING: Do *not* add tests using ErrorLevel after this section
2356 should_not_exist 2> nul > nul
2358 rem nt 4.0 doesn't really support a way of setting errorlevel, so this is weak
2359 rem See http://www.robvanderwoude.com/exit.php
2362 if errorlevel 2 echo errorlevel too high, bad
2363 if errorlevel 1 echo errorlevel just right, good
2364 if errorlevel 01 echo errorlevel with leading zero just right, good
2365 if errorlevel -1 echo errorlevel with negative number OK
2366 if errorlevel 0x1 echo hexa should not be recognized!
2367 if errorlevel 1a echo invalid error level recognized!
2369 echo abc%ErrorLevel%def
2370 if errorlevel 1 echo errorlevel nonzero, bad
2371 if not errorlevel 1 echo errorlevel zero, good
2372 if not errorlevel 0x1 echo hexa should not be recognized!
2373 if not errorlevel 1a echo invalid error level recognized!
2374 rem Now verify that setting a real variable hides its magic variable
2376 echo %ErrorLevel% should be 7
2377 if errorlevel 7 echo setting var worked too well, bad
2379 echo %ErrorLevel% should still be 7
2381 echo ------------ Testing GOTO ------------
2384 echo goto with no leading space worked
2387 echo goto with a leading space worked
2390 echo goto with a leading tab worked
2393 echo goto with a following space worked
2395 echo ------------ Testing PATH ------------
2396 set WINE_backup_path=%path%
2403 set path=%WINE_backup_path%
2404 set WINE_backup_path=
2406 echo ------------ Testing combined CALLs/GOTOs ------------
2407 echo @echo off>foo.cmd
2408 echo goto :eof>>foot.cmd
2410 echo echo world>>foo.cmd
2412 echo @echo off>foot.cmd
2413 echo echo cheball>>foot.cmd
2415 echo call :bar>>foot.cmd
2416 echo if "%%1"=="deleteMe" (del foot.cmd)>>foot.cmd
2417 echo goto :eof>>foot.cmd
2420 echo echo barbare>>foot.cmd
2421 echo goto :eof>>foot.cmd
2427 rem Script execution stops after the following line
2450 echo Final message is not output since earlier 'foot' processing stops script execution
2451 echo Do NOT add any tests below this line
2453 echo ------------ Done, jumping to EOF -----------
2455 rem Subroutine to set errorlevel and return
2456 rem in windows nt 4.0, this always sets errorlevel 1, since /b isn't supported
2459 rem This line runs under cmd in windows NT 4, but not in more modern versions.