我试图循环遍历所有参数,然后我希望它被url编码。它目前有效但不能用单引号之类的东西。防爆。外面的天气怎么样?
这就是我的尝试:
for var in "$@"
do
n+="$var "
done
h="${n%?}"
export h
urlencode() { python -c "import os, sys, urllib as ul; print ul.quote_plus(os.environ['h'])"; }
e=$(urlencode "$h")
t=$(curl -s --request GET "http://example.com/?q=$e")
echo $t