shell2http
shell2http copied to clipboard
Passing Spaces in `$v_params` to Command
Running the utility in --form mode, I’m trying to write a simple passthrough, essentially in the form of:
shell2http --form --no-index --port=$PORT /exec './my-utility $v_args'
The way $v_name currently works presents multiple issues I found while tinkering with this:
- Using double quotes for the command causes
v_argsto be expanded immediately andshell2httpwill no longer substitute for obvious reasons. - Because the
v_argsneeds to be preserved as is, it’s not possible to use other env vars, e.g. aUTIL_PATHto the utility that should be called here. Only implicitly used variables (like$PATH) can be used. - If
v_argscontains spaces after URI component decoding, content is cut off.
As an example, building an /mkdir 'mkdir $v_args' with an argument containing spaces ("my dir") and playing around with quotation yields all variations of /my, /'my, /"my, and my favourite, /$v_args, but never actually creates a /my dir.
I’m in a spot where it seems most sensible to use some sort of additional coding and passing that to a proxy first; this could be a shell script that takes encoded v_args in, decodes spaces and other possibly conflicting characters and only then calls the intended utility. However, this clashes with the simplicity that led me to shell2http in the first place.
Sorry, response may be delayed, we have a war, russia attacked my country.
If there's anything us random internet geeks can do to help, do let us know :(
Hi @AugustSaintFreytag,
shell quoting is hard 🙂
for using var in-place you need single quotes, and for values with spaces you need double quotes, something like this:
shell2http -form /md 'mkdir "$v_args"'
and:
curl 'http://localhost:8080/md?args=111+232'
but sometimes it is more convenient to use a separate script, where quoting can be easier:
shell2http -form /md ./script.sh