如何在bash中传递带有空格的参数?

时间:2018-08-16 08:02:10

标签: bash sh

想要传递带有空格的字符串参数,如下所示:

get_post_data()
{
  cat <<EOF
{"incident":{"type":"incident","title":"$1","service":{"id":"123","type":"service_reference"}}}
EOF
}

send_notification()
{
  curl -X POST --header 'Content-Type: application/json' ... -d "$(get_post_data $1)" 'https://api.service.com/incidents'
}

send_notification Hello World!

0 个答案:

没有答案