zsh上which是用的zsh内置命令whence,在bash中用的是/usr/bin/which命令。
这两种的输出结果不一样。参考下面的命令行输出。
➜ ~ which ls
ls: aliased to ls --color=tty
➜ ~ whence ls
ls --color=tty
➜ ~ /usr/bin/which ls
/bin/ls
在很多脚本中,会用bash的which获取命令的完整路径并直接引用,在zsh中这种脚本就会报错。
work around:把which通过alias修改为/usr/bin/which命令。
➜ ~ alias which=/usr/bin/which