Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Why does a token starting with '=' change semantics of a command in zsh?

The following shell command requires no explanation

a=1

However, when an extra space is added, zsh gives an unexpected error

a =1
zsh: 1 not found

Could someone explain this, please? What is the meaning of ‘=’ is zsh?

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Bash produces an error that I expected:

a =1
bash: a: command not found

>Solution :

The fine manual says:

`=' 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.

Thus:

%echo =ls
/bin/ls
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading