Fix shellcheck and shfmt issues

- Add double quotes around variables to prevent globbing
- Fix parameter expansion quoting in ${domain%.${_zone}}
- Remove trailing whitespace for shfmt compliance
This commit is contained in:
Kilian Ries
2026-01-22 17:04:43 +01:00
parent b4ac517c7b
commit 01c93b9bbd

View File

@@ -212,7 +212,7 @@ $page_zones"
zone_with_dot="${zone}."
if _endswith "$domain." "$zone_with_dot"; then
zone_length=${#zone}
if [ $zone_length -gt $_zone_length ]; then
if [ "$zone_length" -gt "$_zone_length" ]; then
_zone="$zone"
_zone_length=$zone_length
fi
@@ -227,10 +227,10 @@ $page_zones"
# Calculate record name (subdomain part)
# Use parameter expansion instead of sed to avoid regex metacharacter issues
_record_name="${domain%.${_zone}}"
_record_name="${domain%."${_zone}"}"
# Handle case where domain equals zone (remove trailing dot if present)
if [ "$_record_name" = "$domain" ]; then
_record_name="${domain%${_zone}}"
_record_name="${domain%"${_zone}"}"
_record_name="${_record_name%.}"
fi
@@ -343,9 +343,9 @@ _opusdns_wait_for_propagation() {
# Check all OpusDNS authoritative nameservers
for ns in $nameservers; do
if _exists dig; then
result=$(dig @$ns +short "$fulldomain" TXT 2>/dev/null | tr -d '"')
result=$(dig @"$ns" +short "$fulldomain" TXT 2>/dev/null | tr -d '"')
elif _exists nslookup; then
result=$(nslookup -type=TXT "$fulldomain" $ns 2>/dev/null | grep -A1 "text =" | tail -n1 | tr -d '"' | sed 's/^[[:space:]]*//')
result=$(nslookup -type=TXT "$fulldomain" "$ns" 2>/dev/null | grep -A1 "text =" | tail -n1 | tr -d '"' | sed 's/^[[:space:]]*//')
else
_err "Neither dig nor nslookup found. Cannot verify DNS propagation."
return 1