fix bug."head -c" in function _ali_nonce not supported by solaris

This commit is contained in:
lc 2016-11-23 14:29:19 +08:00
parent 9ecfd8ed04
commit 645de061e9

View File

@ -90,9 +90,9 @@ _ali_rest() {
_ali_urlencode() { _ali_urlencode() {
_str="$1" _str="$1"
_str_len=${#_str} _str_len=${#_str}
_h_i=1 _u_i=1
while [ "$_h_i" -le "$_str_len" ]; do while [ "$_u_i" -le "$_str_len" ]; do
_str_c="$(printf "%s" "$_str" | cut -c "$_h_i")" _str_c="$(printf "%s" "$_str" | cut -c "$_u_i")"
case $_str_c in [a-zA-Z0-9.~_-]) case $_str_c in [a-zA-Z0-9.~_-])
printf "%s" "$_str_c" printf "%s" "$_str_c"
;; ;;
@ -100,12 +100,12 @@ _ali_urlencode() {
printf "%%%02X" "'$_str_c" printf "%%%02X" "'$_str_c"
;; ;;
esac esac
_h_i="$(_math "$_h_i" + 1)" _u_i="$(_math "$_u_i" + 1)"
done done
} }
_ali_nonce() { _ali_nonce() {
tr </dev/urandom -dc A-Za-z0-9 | head -c 32 cat /dev/urandom | _head_n 1 | _digest "sha256" hex | cut -c 1-31
} }
_check_exist_query() { _check_exist_query() {