What special meaning does an equal-sign have in zs

2019-04-21 12:57发布

问题:

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:

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