3

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
}
4

1 に答える 1

1

bash-completion のベータ版 (1.99) を使用しています。代わりに最新の安定版 (1.3) を試すことができます。

ベータ版が本当に必要な場合は^(\$\{?)([A-Za-z0-9_]*)$、行の正規表現を引用符で囲む必要がありますif [[ $cur =~ ^(\$\{?)([A-Za-z0-9_]*)$ ]]; then。演算子 =~ の処理は、bash バージョンによって異なります (IIRC 以前の 3.2 引用符が必要です)。

于 2012-02-05T19:35:54.133 に答える