I am issuing a curl command that would ideally look like this (note that this is incorrect due to lack of escaping):
curl -X POST --data-urlencode 'payload={"channel": "@somebody", "text": "I'm sending you a test message. Let me know if you get it."}' https://hooks.slack.com/services/XXX
The single quote in the word I'm causes this to fail. However, I am unsure how to escape this quote since there are several levels of nested quotes.
As a second question, what if there were double quotes inside the text string? How could those be escaped?
I have read about escaping and looked at other SO posts (including How to escape single-quotes within single-quoted strings?), but I can't seem to get any solutions to work. The linked post talks about single quotes in single quotes and solves that problem by using double quotes. However, my single quote is already in double quotes. So this is more complicated.
Thanks so much for your help.
$'stuff'
and escape the single quotes in it. – Wiesecurl -X POST --data-urlencode 'payload={"channel": "@somebody", "text": "I'\''m sending you a test message. Let me know if you get it."}' https://hooks.slack.com/services/XXX
– Pulse