zsh中的等号有什么特殊含义? [英] What special meaning does an equal-sign have in zsh?

查看:116
本文介绍了zsh中的等号有什么特殊含义?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的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

从命令行进行的实验发现,当出现等号时,shell会感到沮丧:

Experimenting from the command line, I found that the shell gets upset when there is an equal sign:

$ echo =z
zsh: z not found

但是在这里,我们有:

$ echo =echo
/usr/bin/echo

根据此观察结果,看起来

From this observation, it looks, as if

=XXX

将被解释为

$(which XXX)

但是,我没有在zsh联机帮助页中找到有关此替换"的任何信息.这块魔法在哪里描述?

However, I didn't find anything about this "substitution" in the zsh manpage. Where is this piece of magic described?

推荐答案

来自

14.7.3‘='扩展

14.7.3 ‘=’ expansion

如果单词以不带引号的'='开头并且设置了EQUALS选项, 单词的其余部分用作命令的名称.如果一个 该命令以该名称存在,该词由完整路径名替换 命令.

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.

此处多用文字

这篇关于zsh中的等号有什么特殊含义?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆