执行man diff
会告诉您:
NAME
diff - compare files line by line
SYNOPSIS
diff [OPTION]... FILES
DESCRIPTION
Compare files line by line.
-i --ignore-case
Ignore case differences in file contents.
[...]
-q --brief
Output only whether files differ.
[...]
但是当我使用-q
选项时,它会失败并显示fatal: invalid diff option/value: -q
为什么diff命令的人与安装的版本不对应?
如何解决?
是否有一个brew包,其中包含带有-q
选项的diff命令版本?
(brew coreutils和binutils没有diff命令)
OSX 10.11.5
更新您的问题
$ which diff
/usr/bin/diff
$ diff --version
usage: git diff --no-index <path> <path>
$ diff -v
usage: git diff --no-index <path> <path>
$ command diff --version
diff (GNU diffutils) 2.8.1
我使用brew和https://github.com/donnemartin/dev-setup
如果我停用dev-setup安装的.bash_profile
,那么which diff
仍会返回相同的路径,但diff -q
有效。
答案 0 :(得分:1)
你是否有机会使用类似pretzo之类的东西?像这样的一些框架将(严重地)定义它们自己的函数来替换终端默认函数。
在这种情况下,请尝试运行command diff -q ...
并查看是否可以解决问题。
修改:正如@MarkPlotnick指出的那样,dev-setup是另一个覆盖默认diff
命令并使用git diff
代替的框架:
# Use Git’s colored diff when available
hash git &>/dev/null;
if [ $? -eq 0 ]; then
function diff() {
git diff --no-index --color-words "$@";
}
fi;
参考:https://github.com/donnemartin/dev-setup/blob/master/.functions