On Thu Aug 31 16:41:05 2023 +0000, Dmitry Sokolov wrote:
The ERRORLEVEL check is not enough. There should be a separate variable to hold the status of the last command. https://ss64.com/nt/errorlevel.html
Even though a CMD batch script should set or reset ERRORLEVEL after every command, there are a few exceptions:
Commands that do NOT affect the ERRORLEVEL: \ BREAK, ECHO, ENDLOCAL, FOR, IF, PAUSE, REM, RD/RMDIR, TITLE
Commands that will set but not clear an ERRORLEVEL: \ CLS, GOTO, KEYS, POPD, SHIFT
Commands that set an Exit Code but not the ERRORLEVEL: \ RD/RMDIR
Commands that set an ERRORLEVEL but not the Exit Code ([SO explanation](https://stackoverflow.com/questions/34936240/batch-goto-loses-errorlevel/349...)): \ MD/MKDIR in that case:
* do we have test cases that support these affirmations (from a cursory look, we have tests for errorlevel, but perhaps not with 100% coverage, but very few for exit code) * I don't like adding another global variable; it would be more natural for each command (built-in or external) to return its exit code and use it in chaining & redirection operators -- https://gitlab.winehq.org/wine/wine/-/merge_requests/3671#note_44288