想要传递带有空格的字符串参数,如下所示:
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!