
It's been known that for/l loops run in their own special "mode", and can't be really broken out of short of a hard "exit". Maybe related, here is another peculiar for/l behavior. Using the following two batch files...
Code: Select all
:: for-l.cmd
@echo off
echo ^>^>^>
for /l %%n in (1,1,3) do echo-one %%n
echo ^<^<^< &rem never reached
Code: Select all
:: echo-one.cmd
@echo off
echo [%0]: %*
Code: Select all
C:\tmp>for-l
>>>
[echo-one]: 1
C:\tmp>echo-one 2
[echo-one]: 2
C:\tmp>echo-one 3
[echo-one]: 3
Note the two "C:\tmp>echo-one" lines. It's as if, after the first iteration, echo gets turned back on. No idea how or why, but the behavior is consistent.
Liviu