Closed Hraesvel closed 1 year ago
workaround for this is to create one arg for the flag and one for the content.
.arg("-H")
.arg("Auth: ....")
workaround for this is to create one arg for the flag and one for the content.
.arg("-H") .arg("Auth: ....")
That is the intended way, every argument has to pass separately.
It is the same as std::process
or tokio::process
, every argument has to be passed separately.
You can use args([...])
which can pass an array or a slice to simplify this.
turns out the shell-escape is adding a few more single/double quotes.
Because you pass that as a simple argument, so shell-escape will escape every '
in them in order to pass it as a single argument and not be reinterpreted as multiple argument.
curl -H 'Auth' some_host_ip -o 'stuff.txt'
This command contains the following arguments:
curl
, also the program name-H
Auth
some_host_ip
-o
stuff.txt
When you passed this to bash
, it will split them based the syntax: everything quoted will be treated as a single argument, everything else will be split based on ascii whitespace.
Thanks for the response. that's good to know, I'll update my automation code to split up cmds into tokens.
@Hraesvel You can try shlex which does splitting in the same manner as POSIX shell
@NobodyXu Ha I wish I saw this, just spent the last hour or so creating a Nom parser to handle complex curl cmd strings. This crate will likely do a better job than my quick write up.
I will close this issue then
Was trying to do a curl and notice that the args would fail. turns out the shell-escape is adding a few more single/double quotes.
try something like this and review the data structure. I think you need to use a different crate as shell-escape hasn't been updated in years.