man diff 与安装的 diff 版本不对应
man diff does not correspond to the diff version installed
执行 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命令的man和安装的版本不对应?
如何解决?
有没有带有 -q
选项的 diff 命令版本的 brew 包?
(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
仍然 returns 相同的路径,但 diff -q
有效。
你有没有使用过 pretzo 或类似的东西?像这样的一些框架将(糟糕地)定义自己的函数来替换终端默认函数。
在这种情况下,请尝试 运行 command diff -q ...
看看是否可以解决问题。
Edit:正如@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
执行 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命令的man和安装的版本不对应?
如何解决?
有没有带有 -q
选项的 diff 命令版本的 brew 包?
(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
仍然 returns 相同的路径,但 diff -q
有效。
你有没有使用过 pretzo 或类似的东西?像这样的一些框架将(糟糕地)定义自己的函数来替换终端默认函数。
在这种情况下,请尝试 运行 command diff -q ...
看看是否可以解决问题。
Edit:正如@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