【发布时间】:2012-02-02 12:51:15
【问题描述】:
我尝试为 MSYS bash 安装 bash-completion,但它似乎包含一些语法错误。 它失败并显示以下消息
bash: /usr/local/share/bash-completion/bash_completion: line 625: syntax error in conditional expression: unexpected token `('
bash: /usr/local/share/bash-completion/bash_completion: line 625: syntax error near `^(\'
bash: /usr/local/share/bash-completion/bash_completion: line 625: ` if [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then'
这是失败的代码
# Complete variables.
# @return True (0) if variables were completed,
# False (> 0) if not.
_variables()
{
if [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then
[[ $cur == *{* ]] && local suffix=} || local suffix=
COMPREPLY+=( $( compgen -P ${BASH_REMATCH[1]} -S "$suffix" -v -- \
"${BASH_REMATCH[2]}" ) )
return 0
fi
return 1
}
【问题讨论】:
-
可能上面的代码是针对更高版本的bash,而不是“BASH_VERSION='3.1.17(1)-release'”(至少在我安装的MSYS中)。任何 Bash 专家愿意发表评论吗?祝你好运。
标签: regex bash msys bash-completion