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

落爺英雄遲暮 提交于 2019-12-10 02:52:28

问题


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



来源:https://stackoverflow.com/questions/28606988/what-special-meaning-does-an-equal-sign-have-in-zsh

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!