什么是Windows命令外壳相当于bash中的'真'的命令? [英] What's the Windows command shell equivalent of bash's `true` command?

查看:249
本文介绍了什么是Windows命令外壳相当于bash中的'真'的命令?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经写了vim的插件,弹到运行外部命令。我运行的命令的两个差异的grep 这可每个出口有一个非零退出code在正常运行。

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.

差异,退出code退出1当它发现差异和的grep ,退出$ C退出$ C 1,当它没有找到匹配。)

(diff exits with exit code 1 when it finds differences and grep exits with exit code 1 when it doesn't find matches.)

有关我的Vimscript的目的,我需要从这些命令返回0作为退出code。到目前为止,我构建这样的命令:

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

grep foo bar || true

这对我的作品在OS X上,它显然适用于一些Windows用户。然而,当我上通过VirtualBox的OS X上运行的Windows 7,利用git的安装程序安装的bash中,我得到的错误消息:真不被识别为一个内部或外部命令,可操作的程序或批处理文件。

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.

什么是正确的成功,无操作命令在Windows上使用?

What is the correct successful-no-op command to use on Windows?

推荐答案

真正大致相当于(退出0)(括号创建以状态0退出,而不是退出当前的shell,一个子shell。

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

这篇关于什么是Windows命令外壳相当于bash中的'真'的命令?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆