What's the Windows command shell equivalent of Bash's `true` command?

VER>NUL

works for me.

For example,

MKDIR . || VER>NUL

issues an error message, but it sets %ERRORLEVEL% to 0.


true is roughly equivalent to (exit 0) (the parentheses create a subshell that exits with status 0, instead of exiting your current shell.


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

Tags:

Shell

Git

Bash

Cmd