This commit is contained in:
Zhong Lufan
2020-01-10 12:43:35 +08:00
parent c6ae46f33c
commit 7e6b2eecca
2 changed files with 9 additions and 4 deletions

View File

@@ -57,11 +57,12 @@ aliapi_rpc() {
local _http_host=$1 _http_method=$2
local _query_str=""
local _key _value
local i
for (( i = 0; i < ${#_ali_key[@]}; ++i )); do
_key=${_ali_key[$i]}
_value=${_ali_value[$i]}
# 参数值如果是以 () 结束,代表需要执行函数获取值,如果函数不存在,使用原始值。
[[ ($(grep -E "^.+\(\)$" <<< "$_value") == "$_value" && $(type -t ${_value//()/}) == "function") ]] && _value=$(${_value//()/})
[[ ($(grep -E "^.+\(\)$" <<< "$_value") == "$_value" && $(type -t "${_value//()/}") == "function") ]] && _value=$(${_value//()/})
_value=$(_urlencode "$_value")
_query_str+="$_key=$_value&"
done