https://bugs.winehq.org/show_bug.cgi?id=57139
Bug ID: 57139 Summary: SET changes errorlevel in .bat files Product: Wine Version: 9.16 Hardware: x86-64 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: cmd Assignee: wine-bugs@winehq.org Reporter: huangqinjin@gmail.com Distribution: ---
errorlevel was changed to 0 after SET, while Windows CMD keep it unchanged.
Quote from https://stackoverflow.com/a/34968021 and https://stackoverflow.com/a/148991:
The differences between .CMD and .BAT as far as CMD.EXE is concerned are: With extensions enabled, PATH/APPEND/PROMPT/SET/ASSOC in .CMD files will set ERRORLEVEL regardless of error. .BAT sets ERRORLEVEL only on errors.
test.bat:
@echo off
call :SetError
echo %errorlevel% echo %errorlevel% SET x= echo %errorlevel%
exit /B 0
:SetError exit /B 2