I am writing a script to execute CURL commands for a given user input. The script has several helper functions for creating a list of parameters (arguments) that will ultimately be passed to CURL.
The above example is as follows:
#!/bin/bash
function create_arg_list
{
local __hdr="x-madhurt-test:madh urt"
local __params="http://google.co.in -X GET -H '$__hdr'"
local __resultvar="$1"
eval $__resultvar="\"$__params\""
echo "params after eval : $__resultvar"
}
create_arg_list arg_list
echo "params after eval in main code : $arg_list"
echo "Running command : curl -v $arg_list"
curl -v $arg_list
The script works fine when the input parameters (file path, URL, etc.) have (quoted) spaces in them. However, when the arguments to be passed as HTTP headers in CURL contain spaces, the script fails.
Here is what I tried:
- , ?