Browse Source

Fix shellcheck SC2181: Check exit code directly

pull/6789/head
abooraja 7 days ago
parent
commit
97b1b74f67
  1. 26
      dnsapi/dns_arvan.sh

26
dnsapi/dns_arvan.sh

@ -206,29 +206,35 @@ _arvan_rest() {
if [ "$mtd" = "DELETE" ]; then if [ "$mtd" = "DELETE" ]; then
#DELETE Request shouldn't have Content-Type #DELETE Request shouldn't have Content-Type
_debug data "$data" _debug data "$data"
response="$(_post "$data" "$ARVAN_API_URL/$ep" "" "$mtd")"
if ! response="$(_post "$data" "$ARVAN_API_URL/$ep" "" "$mtd")"; then
_err "Error on Arvan API request"
return 1
fi
elif [ "$mtd" = "POST" ]; then elif [ "$mtd" = "POST" ]; then
export _H2="Content-Type: application/json" export _H2="Content-Type: application/json"
export _H3="Accept: application/json" export _H3="Accept: application/json"
_debug data "$data" _debug data "$data"
response="$(_post "$data" "$ARVAN_API_URL/$ep" "" "$mtd")"
if ! response="$(_post "$data" "$ARVAN_API_URL/$ep" "" "$mtd")"; then
_err "Error on Arvan API request"
return 1
fi
else else
# برای GET request # برای GET request
if [ -n "$ep" ]; then if [ -n "$ep" ]; then
# اگر ep مشخص شده، به endpoint خاص درخواست می‌زنیم # اگر ep مشخص شده، به endpoint خاص درخواست می‌زنیم
response="$(_get "$ARVAN_API_URL/$ep")"
if ! response="$(_get "$ARVAN_API_URL/$ep")"; then
_err "Error on Arvan API request"
return 1
fi
else else
# اگر ep خالی است، لیست دامنه‌ها را می‌گیریم # اگر ep خالی است، لیست دامنه‌ها را می‌گیریم
response="$(_get "$ARVAN_API_URL")"
if ! response="$(_get "$ARVAN_API_URL")"; then
_err "Error on Arvan API request"
return 1
fi
fi fi
fi fi
# چک کردن موفقیت درخواست
if [ "$?" != "0" ]; then
_err "Error on Arvan API request"
return 1
fi
_debug2 response "$response" _debug2 response "$response"
return 0 return 0
} }
Loading…
Cancel
Save