What special meaning does an equal-sign have in zs

2019-04-21 12:26发布

In my zsh script, I had a line

echo some text ================================

To my surprise, an error message was issued for this line:

zsh: =============================== not found

Experimenting from the command line, I found that the shell gets upset when there is an equal sign:

$ echo =z
zsh: z not found

But here, we have:

$ echo =echo
/usr/bin/echo

From this observation, it looks, as if

=XXX

would be interpreted like

$(which XXX)

However, I didn't find anything about this "substitution" in the zsh manpage. Where is this piece of magic described?

1条回答
聊天终结者
2楼-- · 2019-04-21 12:58

From the docs:

14.7.3 ‘=’ expansion

If a word begins with an unquoted ‘=’ and the EQUALS option is set, the remainder of the word is taken as the name of a command. If a command exists by that name, the word is replaced by the full pathname of the command.

And here in more words

查看更多
登录 后发表回答