The following is a script where the empty variable is replaced by single quotes. If the variable is not empty then we have the correct substitution.
$ set -x; aa=""; bb=`curl "$aa" -vvv`; set +x
+ aa=
++ curl '' -vvv
The thing to notice is the single quotes in place of the empty variable.
When variable is not empty, everything works fine as in:
$ set -x; aa="google.com"; bb=`curl "$aa" -vvv`; set +x
+ aa=google.com
++ curl google.com -vvv
Q1: Why is an empty variable or a variable with space resulting in single quotes being introduced? Q2: How do I prevent the single quotes in lieu of the empty variable?
Now, I can remove the double quotes and everything works fine but I need to preserve spaces if there are any.
Thanks.