我写了一个 Vim 插件,可以运行外部命令。我运行的两个命令是 diff
和 grep
,它们在“正常”操作期间都可以以非零退出代码退出。
(diff
在发现差异时以退出代码 1 退出,而 grep
在未找到匹配项时以退出代码 1 退出。)
出于我的 Vimscript 的目的,我需要从这些命令返回退出代码 0。到目前为止,我正在构建这样的命令:
diff a b || true
和:
grep foo bar || true
这对我在 OS X 上有效,显然对某些 Windows 用户也有效。但是,当我通过 VirtualBox 在 OS X 上运行 Windows 7 时,使用 Git 安装程序安装的 Bash,我收到错误消息:
'true' is not recognized as an internal or external command, operable program or batch file.
在 Windows 上正确使用的 successful-no-op 命令是什么?
最佳答案
VER>NUL
对我有用。
例如,
MKDIR . || VER>NUL
发出错误消息,但将 %ERRORLEVEL%
设置为 0。
关于git - 与 Bash 的 `true` 命令等效的 Windows 命令 shell 是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22046780/