Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

Fixed %@REPEAT doesn't die gracefully or throw errormessage or errorlevel when fed negative number

Jul
534
10
Perhaps there's some holistic reason why this isn't a bug... That always seems to be the case.

But script execution is being halted without finishing AND without setting any kind of errorlevel....

@echo off
echo Alpha
echo %@REPEAT[X,1] for all!
echo Beta
echo %@REPEAT[X,0] for all!
echo Omega
echo %@REPEAT[X,-1] for all!
echo Jingle bells?


Execution simply stops when repeat is given a -1 [which can be a result of various code mistakes when creating spacing text]:
1729021547398.webp


No error message. Not even the errorlevel that is set when an internal command fails [my errorlevel.bat checks all this]. We never get to "jingle bells"

I'm sure at the very least this is meant to set an errorlevel on fail ... But stopping script execution instead of displaying an error message and continuing definitely feel s like a bad bug.
 
I don't have access to the source code, but I can make a wild guess. The repeat count is probably a unsigned integer; negative values make no sense in this context! So your -1 probably gets cast to, say, 4,294,967,295, and the @REPEAT function blows way, way past the end of its buffer....
 
I see this in WinDbg when I echo %@repeat[x,-1]

(13bc.8a0): C++ EH exception - code e06d7363 (first chance)
(13bc.8a0): C++ EH exception - code e06d7363 (first chance)
 
Back
Top