Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 353
user1934428 Avatar asked Feb 19 '15 12:02

user1934428


People also ask

What is symbol in shell script?

symbol or operator in Linux can be used as Logical Negation operator as well as to fetch commands from history with tweaks or to run previously run command with modification. All the commands below have been checked explicitly in bash Shell. Though I have not checked but a major of these won't run in other shell.

What does zsh mean in terminal?

What is Zsh? Zsh, also known as the Z shell, extends functionality of the Bourne Shell (sh), offering newer features and more support for plugins and themes. Starting with MacOS Catalina in 2019, Zsh became the default login and interactive shell in Mac machines.

How do you declare an array in zsh?

From man zshbuiltins , under the entry for typeset (of which declare is a synonym): For each name=value assignment, the parameter name is set to value. Note that arrays currently cannot be assigned in typeset expressions, only scalars and integers.

What does quote mean in terminal?

Quoting is used to remove the special meaning of characters or words: quotes can disable special treatment for special characters, they can prevent reserved words from being recognized as such and they can disable parameter expansion.


1 Answers

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

like image 139
Maximilian Kindshofer Avatar answered Oct 25 '22 14:10

Maximilian Kindshofer