Reputation: 1
This is very similar to Prevent bash from adding single quotes to variable output, but none of those answers are helping me.
This script:
set -ex
curl_headers=(
--silent
"--form release_description=$'\n new \n'"
)
curl "${curl_headers[@]}" "example.com"
Returns this output:
+ curl_headers=(--silent "--form release_description=$'\n new \n'")
+ curl --silent '--form release_description=$'\''\n new \n'\''' example.com
It's doing two things I don't want. It's adding a single tick before --form
and it's escaping the single ticks in my release_description
The desired result is:
curl --silent --form release_description=$'\n new \n' example.com
How do I get it to remove the escape sequences and added single ticks?
Upvotes: 0
Views: 497
Reputation: 532303
The single quotes are just how trace mode (from the -x
option) displays the string; it doesn't affect your command at all. The main problem is that you are combining two separate arguments (--form
and its argument) into one.
The correct script should be something like
set -ex
curl_headers=(
--silent
--form
release_description=$'\n new \n'
)
curl "${curl_headers[@]}" "example.com"
Upvotes: 3