I have written a Vim plugin which shells out to run external commands. Two of the commands I run are diff and grep which can each exit with a non-z
true is roughly equivalent to (exit 0) (the parentheses create a subshell that exits with status 0, instead of exiting your current shell.
cd .
also sets %ERRORLEVEL% to 0 but runs a bit faster and writes a bit shorter than ver>nul. Example:
mkdir . 2>nul || cd .
The context is a Windows cmd shell (used by the git-cmd.bat script):
Following "Exiting batch with EXIT /B X where X>=1 acts as if command completed successfully when using && or || operators between batch calls", you could define in your path a true.bat file with:
@%COMSPEC% /C exit 1 >nul
VER>NUL
works for me.
For example,
MKDIR . || VER>NUL
issues an error message, but it sets %ERRORLEVEL% to 0.