macOS Sierra:${TAIL} 在 zsh 中不工作

macOS Sierra: ${TAIL} is not working in zsh

我试图在 zsh (oh-my-zsh) 中执行一些 bash 脚本。我发现 ${TAIL} 在 zsh 中不工作。

bash:

bash-3.2$ ${CD} /tmp; echo "test" >> test.txt; ${TAIL} test.txt
bash: /tmp: is a directory
test

zsh:

~ ${CD} /tmp; echo "test" >> test.txt; ${TAIL} test.txt
zsh: command not found: tail -f
✘ /tmp

但是直接用tail就可以了

✘ /tmp tail -f test.txt
test
test

whereis tail
/usr/bin/tail
echo $PATH
/usr/local/bin:/usr/bin

我认为这是 zshWhy does $var where var="foo bar" not do what I expect?

的经典案例

bash 不同,默认情况下,zsh 在传递给命令或在循环中用作 for foo in $var 时不会拆分为单词。

var="foo bar"

手动启用标志为

setopt shwordsplit

然后尝试与

相同的方法
echo "test" >> test.txt; ${TAIL} test.txt