Well, I saw a lot of advice on this but no real solution - just some debugging 
help.

At least from my own experience with Bash Scripting, I find that you can never 
use enough braces when referencing variables.

So, the script should read:

url="http://mypage";
curl_opts="-x"
curl ${url} -d \"mydata\" ${curl_opts}


I would probably even go one further and use quotes in the final line as well, 
thus producing:

curl "${url}"-d \"mydata\" "${curl_opts}"

Please note that the single and double quotes have meanings as far as expansion.

Also, the guys on IRC (#bash) are quite helpful - a great resource in addition 
to 'man bash'.

$0.02

Ben


----- Original Message ----
> From: Xi Shen <davidshe...@googlemail.com>
> To: gentoo-user <gentoo-user@lists.gentoo.org>
> Sent: Mon, May 9, 2011 1:44:58 AM
> Subject: [gentoo-user] [OT] bash script error
> 
> It is not specific to Gentoo. But do not know where to search or post it  :)
> 
> My script looks like:
> 
> url="http://mypage";
> curl_opts="-x  ''"
> curl $url -d \"mydata\" $curl_opts
> 
> If I execute it, I got an error  from curl, saying it cannot resolve
> the proxy ''.
> 
> But If I modify the  script to:
> 
> url="http://mypage";
> curl $url -d \"mydata\" -x ''
> 
> It works  fine.
> 
> I guess there's something wrong with the argument expansion. Just  do
> not know how to fix it. Please help.
> 
> 
> -- 
> Best Regards,
> Xi  Shen (David)
> 
> http://twitter.com/davidshen84/
> 
> 

Reply via email to