首页 文章

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

提问于
浏览
2

我试图在zsh(oh-my-zsh)中执行一些bash脚本 . 我发现$ 在zsh中不起作用 .

庆典:

bash-3.2 $ $ / tmp; echo“test”>> test.txt; $ test.txt bash:/ tmp:是目录测试

zsh的:

〜$ / tmp; echo“test”>> test.txt; $ test.txt zsh:找不到命令:tail-f✘/ tmp

但直接使用尾巴很好

✘/ tmp tail -f test.txt test test whereis tail / usr / bin / tail echo $ PATH / usr / local / bin:/ usr / bin

1 回答

  • 1

    我认为这是 zsh 中的经典案例Why 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
    

相关问题