Why not? I always have seen this that way:
Code: Select all
@echo off &setlocal
set "N=10"
for /l %%i in (1 1 %N%) do (
:exitLoop
if %%i==5 goto exitLoop
echo %%i
)
pause
The goto breaks the loop as it doesn't execute the loops content.
The command line interpreter just have to read the virtual document, that is inserted into the batch file by the for loop.
This is done line by line (or loop body by loop body, default) to not oversee any label.
The label cannot be found within the virtual document, as it is removed on the loop body (on normalization) when building the virtual document, so it doesn't find them within the loop.
But it doesn't execute the code, and goes to the next wanted label, so it is working.
Execution is stopped, that's what is wanted.
You should carefully select the number of iterations, as this extends the virtual document.
So do not insert a document of infinite length, the result were far from beeing optimal.
Edited:
I would agree to you if you meant this: the command line processor doesn't ignore this virtual document, although that should be not difficult to implement (and is done in all other for loops).
Then you would mean the outer script loop that implements the script loop: This loop is indeed not interrupted.
penpen
Edit2: Repositioned the text.