I'm trying to pass arguments in a variable to curl
and it fails. I turned on set -x
to get more information, and I'm really confused about all the single quotes I'm seeing here.
curlopts="-ksS -H 'Content-Type:application/x-www-form-urlencoded'"
$ curl "$curlopts" https://localhost
+ curl '-ksS -H '\''Content-Type:application/x-www-form-urlencoded'\''' https://localhost
curl: option -ksS -H 'Content-Type:application/x-www-form-urlencoded': is unknown
curl: try 'curl --help' or 'curl --manual' for more information
It works without quotes like curl $curlopts https://localhost
but I thought it's generally bad practice to use a variable without quotes.