I have an argument to a bash script which could be a string with spaces. How can I use this within a string concatenation such as below:
#!/usr/bin/env bash
curl -X POST -H 'Content-type: application/json' \
--data '{"text":"'$1'"}' https://hooks.slack.com/services/<rest of URL secret!>
From cmd line if I do:
$./myscript.sh oneword
It works perfectly fine. But if I pass a string with spaces:
$./myscript.sh "two words"
curl: (3) [globbing] unmatched close brace/bracket in column 5
invalid_payload%
I have tried all sorts of quoting to concatenate it correctly, but to no avail. Thanks