user1934428
user1934428

Reputation: 22291

What special meaning does an equal-sign have in zsh?

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?

Upvotes: 18

Views: 2711

Answers (1)

Maximilian Kindshofer
Maximilian Kindshofer

Reputation: 2843

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

Upvotes: 18

Related Questions