I need help understanding what the following code in this documentation means.
我需要帮助理解本文档中下列代码的含义。
LBUFFER=${LBUFFER%%(#m)[_a-zA-Z0-9]#}
LBUFFER+=${abbreviations[$MATCH]:-$MATCH}
I learned that LBUFFER
contains the left from the cursor. However, there are 3 things that confuse me.
我了解到LBUFFER包含游标中的左边。然而,有三件事让我困惑。
- What is the
%%
doing? Is it escaping%
? - %在做什么?逃离%吗?
- What does
(#m)[_a-zA-Z0-9]#
do? Is it something likem/[_a-zA-Z0-9]/
in Perl? If so, what is done to the matched string? - 什么(#)[_a-zA-Z0-9]#做什么?它在Perl中类似于m/[_a-zA-Z0-9]/吗?如果是,那么对匹配的字符串做了什么?
- What is the
:-
part doing in the second line? - -在第二行做什么?
Thanks.
谢谢。
1 个解决方案
#1
1
-
${a%%b}
removes the longest occurrence ofb
(which can be a regular expression), froma
.${a% b}从a中删除最长的b(可以是正则表达式)。
-
[_a-zA-Z0-9]#
is a regular expression matching an alphanumeric character (as indicated by the stuff between[]
) zero or more times (specified by the#
glob operator)[_a-zA-Z0-9]#是一个正则表达式,匹配一个字母数字字符(如[]之间的内容所示)零次或多次(由# glob操作符指定)
-
(#m)
populates the$MATCH
variable after evaluating the previous regular expression.(#m)在计算之前的正则表达式之后填充$MATCH变量。
-
The combination of 1, 2, and 3 means that the stretch of alphanumeric characters at the end of the
$LBUFFER
is deleted and stored in$MATCH
.1、2和3的组合意味着$LBUFFER末尾的字母数字字符的扩展被删除并存储在$MATCH中。
-
${a:-b}
makesa
equal tob
only ifa
is not defined.${a:-b}只在未定义a时才使a等于b。
If you want to learn more, take a look at the expansion chapter of the zsh manual.
如果您想了解更多,请查看zsh手册的扩展章节。
#1
1
-
${a%%b}
removes the longest occurrence ofb
(which can be a regular expression), froma
.${a% b}从a中删除最长的b(可以是正则表达式)。
-
[_a-zA-Z0-9]#
is a regular expression matching an alphanumeric character (as indicated by the stuff between[]
) zero or more times (specified by the#
glob operator)[_a-zA-Z0-9]#是一个正则表达式,匹配一个字母数字字符(如[]之间的内容所示)零次或多次(由# glob操作符指定)
-
(#m)
populates the$MATCH
variable after evaluating the previous regular expression.(#m)在计算之前的正则表达式之后填充$MATCH变量。
-
The combination of 1, 2, and 3 means that the stretch of alphanumeric characters at the end of the
$LBUFFER
is deleted and stored in$MATCH
.1、2和3的组合意味着$LBUFFER末尾的字母数字字符的扩展被删除并存储在$MATCH中。
-
${a:-b}
makesa
equal tob
only ifa
is not defined.${a:-b}只在未定义a时才使a等于b。
If you want to learn more, take a look at the expansion chapter of the zsh manual.
如果您想了解更多,请查看zsh手册的扩展章节。