apt install:正規表現とvar = regexの違い

apt install:正規表現とvar = regexの違い

現在、適切なインストールスクリプトに問題があり、その理由を理解できません。

違いは何ですか:

# works fine
apt install gstreamer1.0-plugins-{bad,base,good,ugly}

そして

var="gstreamer1.0-plugins-{bad,base,good,ugly}"
apt install $var

[...]
E: Unable to locate package gstreamer1.0-plugins-{bad,base,good,ugly}
E: Couldn't find any package by glob 'gstreamer1.0-plugins-{bad,base,good,ugly}'
E: Regex compilation error - Invalid content of \{\}
E: Couldn't find any package by regex 'gstreamer1.0-plugins-{bad,base,good,ugly}'
E: Unable to locate package gstreamer1.0-{omx,alsa}
E: Couldn't find any package by glob 'gstreamer1.0-{omx,alsa}'
E: Regex compilation error - Invalid content of \{\}
E: Couldn't find any package by regex 'gstreamer1.0-{omx,alsa}'

フレンドリーな安否

ベストアンサー1

あなたは支柱の拡張正規表現ではなく、中括弧の拡張は、引用符内または変数の割り当て/拡張では機能しません。

最初のコマンドが実行する操作は次のとおりです。

apt install gstreamer1.0-plugins-bad gstreamer1.0-plugins-base gstreamer1.0-plugins-good gstreamer1.0-plugins-ugly

2番目のコマンドが実行するアクションは次のとおりです。

apt install "gstreamer1.0-plugins-{bad,base,good,ugly}"

おすすめ記事