为什么简单的命令计数器=计数器+ 1在批处理脚本中不起作用?

时间:2015-07-17 10:01:59

标签: windows batch-file gnu-make

我已经制作了一个GNU make文件,以便为count函数批量生成一个简单的脚本。问题是计数器总是为0.你知道解决方案吗?

首先尝试:

__EQUAL := =
$(shell @echo :loop >> checkIfMergingIsEnded.cmd)
$(shell @echo @set counter$(__EQUAL)0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @set /a %counter%+$(__EQUAL)1 >> checkIfMergingIsEnded.cmd)
$(shell @echo @timeout /t 5 >> checkIfMergingIsEnded.cmd)
$(shell @echo @echo %counter% >> checkIfMergingIsEnded.cmd)
$(shell @echo @if %counter% EQU 7 exit /b 0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @goto loop  $(__bracket_close) >> checkIfMergingIsEnded.cmd) 

第二次尝试:

$(shell @echo :loop >> checkIfMergingIsEnded.cmd)
$(shell @echo @set counter=0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @set /a %counter%=%counter%+1 >> checkIfMergingIsEnded.cmd)
$(shell @echo @timeout /t 5 >> checkIfMergingIsEnded.cmd)
$(shell @echo @echo %counter% >> checkIfMergingIsEnded.cmd)
$(shell @echo @if %counter% EQU 7 exit /b 0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @goto loop  $(__bracket_close) >> checkIfMergingIsEnded.cmd)

第三次尝试:

$(shell @echo :loop >> checkIfMergingIsEnded.cmd)
$(shell @echo @set counter=0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @set /a counter=%counter%+1 >> checkIfMergingIsEnded.cmd)
$(shell @echo @timeout /t 5 >> checkIfMergingIsEnded.cmd)
$(shell @echo @echo %counter% >> checkIfMergingIsEnded.cmd)
$(shell @echo @if %counter% EQU 7 exit /b 0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @goto loop  $(__bracket_close) >> checkIfMergingIsEnded.cmd)  

1 个答案:

答案 0 :(得分:0)

所以,这是有效的!谢谢你的帮助:

$(shell @echo @set counter=0 >> checkIfMergingIsEnded.cmd)    
$(shell @echo :loop >> checkIfMergingIsEnded.cmd)
$(shell @echo @set /a counter$(__EQUAL)%counter%+1 >> checkIfMergingIsEnded.cmd)
$(shell @echo @timeout /t 5 >> checkIfMergingIsEnded.cmd)
$(shell @echo @echo %counter% >> checkIfMergingIsEnded.cmd)
$(shell @echo @if %counter% EQU 7 exit /b 0 >> checkIfMergingIsEnded.cmd)
$(shell @echo @goto loop  $(__bracket_close) >> checkIfMergingIsEnded.cmd)