$($string) 実行に失敗しました

$($string) 実行に失敗しました

たとえば$(${StrVar})、私は、私はStrVar価値があります$test$9hp

コマンドを実行すると、$(${StrVar}私の変数内で失敗し、$9拡張を試みます。

function Deploy
{
  # in this function 
  output=$(echo ${1})
  echo "$output" 
}

Deploy "test$9hp"

埋め込み文字列値の実行を防ぐ方法は$9

ベストアンサー1

Deploy "test\$9gh"を使用すると、set -xスクリプトに次のように表示されます。 + Deploy 'test$9hp' ++ echo 'test$9hp' + output='test$9hp' + echo 'test$9hp' test$9hp + set +x 拡張されません。

おすすめ記事