我有一个类似下面的批处理脚本:
for /f "tokens=1,2,3,4" %%G in ("!line!") do (
if not "%%G" == "" (
call :BOOTSTRAP %%G
REM do some processing again here.
echo Some processing...
)
)
这是更大的批处理文件的一部分。我面临的问题是在调用BOOTSTRAP子例程之后,系统继续处理下一个语句。但之后,系统再次使用空参数执行BOOTSTRAP!
这里出了什么问题?
答案 0 :(得分:0)
实际上如果我在循环之后放一个goto:
goto cleanup
:cleanup
REM Do cleanup...
它有效!
如果我调用子程序,我不知道我需要goto或exit。
感谢。
答案 1 :(得分:0)
下一个评论的代码段可以提供帮助:
for /f "tokens=1,2,3,4" %%G in ("!line!") do (
if not "%%G" == "" (
call :BOOTSTRAP "%%G"
REM do some processing again here.
echo Some processing...
)
)
REM do some processing here
rem next goto to skip running in-line: could be `goto :eof` or `exit /B` or even `exit`
goto :anywhere
:BOOTSTRAP
rem processing %~1, i.e. first parameter stripped out of surrounding double quotes
rem next `goto :eof` to return from subroutine: could be `exit /B` instead
goto :eof