scottwinkler / terraform-provider-shell

Terraform provider for executing shell commands and saving output to state file
Mozilla Public License 2.0
279 stars 60 forks source link

Windows, Double Quotes, Interpreter and Curl #94

Open acalbazana opened 3 years ago

acalbazana commented 3 years ago

Hello,

Thanks for the provider. I'd like to see if there is a way around the escaping of double-quotes. When I run a curl command under windows (cmd interpreter), the interpreter escapes double-quotes during script evaluation and confuses curl. I suspect that this isn't the provider's doing, but I'm looking for guidance if anyone has experienced the same and got around it.

Example .bat file contains:

curl --header "Authorization:Bearer %TOKEN%"

However, the following wants to execute after evaluation:

curl --header \"Authorization:Bearer %TOKEN% \" ...

which causes curl to become confused on how to view the command (at least on windows).

I have a workaround where I put the full header (double quotes and all) in the environment/secured-environment block and then use it in my script. Example:

environment = { TOKEN = "\"Authorization: Bearer ...\"" }

Then in script:

curl --header %TOKEN%

which expands the entire header argument properly, without escaping double-quotes when its finally evaluated by the command interpreter.

Anyway... Looking for ideas.

Thanks!

Alejandro