From e440223b40998411c80be06286ff88336fbefc03 Mon Sep 17 00:00:00 2001 From: neilpang Date: Sat, 12 Nov 2016 00:50:44 +0800 Subject: [PATCH] fix shellcheck warnings --- dnsapi/dns_cf.sh | 6 +++--- dnsapi/dns_cx.sh | 4 ++-- dnsapi/dns_dp.sh | 2 +- dnsapi/dns_gd.sh | 3 +-- dnsapi/dns_me.sh | 6 +++--- dnsapi/dns_ovh.sh | 3 +-- 6 files changed, 11 insertions(+), 13 deletions(-) diff --git a/dnsapi/dns_cf.sh b/dnsapi/dns_cf.sh index edd48300..20cb169e 100755 --- a/dnsapi/dns_cf.sh +++ b/dnsapi/dns_cf.sh @@ -41,7 +41,7 @@ dns_cf_add() { return 1 fi - count=$(printf "%s\n" "$response" | _egrep_o \"count\":[^,]* | cut -d : -f 2) + count=$(printf "%s\n" "$response" | _egrep_o "\"count\":[^,]*" | cut -d : -f 2) _debug count "$count" if [ "$count" = "0" ]; then _info "Adding record" @@ -59,7 +59,7 @@ dns_cf_add() { _err "Add txt record error." else _info "Updating record" - record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \" | head -n 1) + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \" | head -n 1) _debug "record_id" "$record_id" _cf_rest PUT "zones/$_domain_id/dns_records/$record_id" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$fulldomain\",\"content\":\"$txtvalue\",\"zone_id\":\"$_domain_id\",\"zone_name\":\"$_domain\"}" @@ -103,7 +103,7 @@ _get_root() { fi if printf "%s" "$response" | grep "\"name\":\"$h\"" >/dev/null; then - _domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | head -n 1 | cut -d : -f 2 | tr -d \") + _domain_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\"" | head -n 1 | cut -d : -f 2 | tr -d \") if [ "$_domain_id" ]; then _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) _domain=$h diff --git a/dnsapi/dns_cx.sh b/dnsapi/dns_cx.sh index 45003745..38649f3e 100755 --- a/dnsapi/dns_cx.sh +++ b/dnsapi/dns_cx.sh @@ -80,7 +80,7 @@ existing_records() { if printf "%s" "$response" | grep '"type":"TXT"' >/dev/null; then count=1 - record_id=$(printf "%s\n" "$seg" | _egrep_o \"record_id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \") + record_id=$(printf "%s\n" "$seg" | _egrep_o "\"record_id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \") _debug record_id "$record_id" return 0 fi @@ -147,7 +147,7 @@ _get_root() { if _contains "$response" "$h."; then seg=$(printf "%s" "$response" | _egrep_o "\{[^\{]*\"$h\.\"[^\}]*\}") _debug seg "$seg" - _domain_id=$(printf "%s" "$seg" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \") + _domain_id=$(printf "%s" "$seg" | _egrep_o "\"id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \") _debug _domain_id "$_domain_id" if [ "$_domain_id" ]; then _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) diff --git a/dnsapi/dns_dp.sh b/dnsapi/dns_dp.sh index 605c541d..a06f157b 100755 --- a/dnsapi/dns_dp.sh +++ b/dnsapi/dns_dp.sh @@ -150,7 +150,7 @@ _get_root() { fi if _contains "$response" "Action completed successful"; then - _domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":\"[^\"]*\" | cut -d : -f 2 | tr -d \") + _domain_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":\"[^\"]*\"" | cut -d : -f 2 | tr -d \") _debug _domain_id "$_domain_id" if [ "$_domain_id" ]; then _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) diff --git a/dnsapi/dns_gd.sh b/dnsapi/dns_gd.sh index fed25d86..f96af937 100755 --- a/dnsapi/dns_gd.sh +++ b/dnsapi/dns_gd.sh @@ -30,7 +30,7 @@ dns_gd_add() { _err "invalid domain" return 1 fi - _debug _domain_id "$_domain_id" + _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" @@ -62,7 +62,6 @@ dns_gd_rm() { #returns # _sub_domain=_acme-challenge.www # _domain=domain.com -# _domain_id=sdjkglgdfewsdfg _get_root() { domain=$1 i=2 diff --git a/dnsapi/dns_me.sh b/dnsapi/dns_me.sh index ba792474..f231f7ed 100755 --- a/dnsapi/dns_me.sh +++ b/dnsapi/dns_me.sh @@ -41,7 +41,7 @@ dns_me_add() { return 1 fi - count=$(printf "%s\n" "$response" | _egrep_o \"totalRecords\":[^,]* | cut -d : -f 2) + count=$(printf "%s\n" "$response" | _egrep_o "\"totalRecords\":[^,]*" | cut -d : -f 2) _debug count "$count" if [ "$count" = "0" ]; then _info "Adding record" @@ -58,7 +58,7 @@ dns_me_add() { _err "Add txt record error." else _info "Updating record" - record_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]* | cut -d : -f 2 | head -n 1) + record_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*" | cut -d : -f 2 | head -n 1) _debug "record_id" "$record_id" _me_rest PUT "$_domain_id/records/$record_id/" "{\"id\":\"$record_id\",\"type\":\"TXT\",\"name\":\"$_sub_domain\",\"value\":\"$txtvalue\",\"gtdLocation\":\"DEFAULT\",\"ttl\":120}" @@ -101,7 +101,7 @@ _get_root() { fi if _contains "$response" "\"name\":\"$h\""; then - _domain_id=$(printf "%s\n" "$response" | _egrep_o \"id\":[^,]* | head -n 1 | cut -d : -f 2) + _domain_id=$(printf "%s\n" "$response" | _egrep_o "\"id\":[^,]*" | head -n 1 | cut -d : -f 2) if [ "$_domain_id" ]; then _sub_domain=$(printf "%s" "$domain" | cut -d . -f 1-$p) _domain="$h" diff --git a/dnsapi/dns_ovh.sh b/dnsapi/dns_ovh.sh index 97730f7e..ed8c42be 100755 --- a/dnsapi/dns_ovh.sh +++ b/dnsapi/dns_ovh.sh @@ -131,7 +131,7 @@ dns_ovh_add() { _err "invalid domain" return 1 fi - _debug _domain_id "$_domain_id" + _debug _sub_domain "$_sub_domain" _debug _domain "$_domain" @@ -221,7 +221,6 @@ _ovh_authentication() { #returns # _sub_domain=_acme-challenge.www # _domain=domain.com -# _domain_id=sdjkglgdfewsdfg _get_root() { domain=$1 i=2