Search code examples
bashmacoszshoh-my-zsh

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


I was trying to execute some bash scripts in zsh (oh-my-zsh). I found ${TAIL} is not working in 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

But using tail directly is fine

✘ /tmp tail -f test.txt
test
test

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


Solution

  • I think this is a classic case in zsh for Why does $var where var="foo bar" not do what I expect?

    Unlike bash, by default, zsh does not split into words when passed to a command or used in a loop as for foo in $var.

    var="foo bar"
    

    enabled the flag manually as

    setopt shwordsplit
    

    then try the same as

    echo "test" >> test.txt; ${TAIL} test.txt