%20%E5%AE%9F%E8%A1%8C%E3%81%AB%E5%A4%B1%E6%95%97%E3%81%97%E3%81%BE%E3%81%97%E3%81%9F.png)
たとえば$(${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
拡張されません。