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-zero exit code during "normal" operation.
(diff
exits with exit code 1 when it finds differences and grep
exits with exit code 1 when it doesn't find matches.)
For the purposes of my Vimscript I need to return an exit code of 0 from these commands. So far I'm constructing the commands like this:
diff a b || true
And:
grep foo bar || true
This works for me on OS X and it apparently works for some Windows users. However, when I run Windows 7 on OS X via VirtualBox, using the Bash installed by the Git installer, I get the error message:
'true' is not recognized as an internal or external command, operable program or batch file.
What is the correct successful-no-op command to use on Windows?
Take a look at PowerShell, which is the closest you will get to a true scripting language like you have in Unix. Other than that, for simple things such as simply runnning an application, take a look at Windows command script/MS-DOS batch files.
What is the Windows Command Prompt? Windows Command Prompt (also known as the command line, cmd.exe or simply cmd) is a command shell based on the MS-DOS operating system from the 1980s that enables a user to interact directly with the operating system.
The winget tool source command allows you to manage sources for Windows Package Manager. With the source command, you can add, list, update, remove, reset, or export repositories.
The command-line shell, sometimes called the command prompt or the terminal, is a tool that lets you control your computer using only textual commands. It offers a lot of power and simplicity (simplicity is different from ease of use).
VER>NUL
works for me.
For example,
MKDIR . || VER>NUL
issues an error message, but it sets %ERRORLEVEL%
to 0.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With