Skip to content

Commit 363d336

Browse files
qfiberclaude
andcommitted
fix(common): resolve_a must not abort under set -e on NXDOMAIN
dig | grep | head pipeline returned 1 when grep found no IPs, which under `set -euo pipefail` killed 05-preflight.sh inside `a=$(resolve_a ...)` before the empty-string branch could handle it. Wrap the pipeline so the function always exits 0 with empty stdout on failure. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent d085361 commit 363d336

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

lib/common.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,8 +217,9 @@ detect_public_ip() {
217217
# Resolve A record for $1 against a public resolver (1.1.1.1).
218218
# Echoes IP or empty.
219219
resolve_a() {
220-
local host="$1"
221-
dig +short +time=2 +tries=1 A "${host}" @1.1.1.1 2>/dev/null | grep -E '^[0-9]+\.' | head -1
220+
local host="$1" out
221+
out=$(dig +short +time=2 +tries=1 A "${host}" @1.1.1.1 2>/dev/null || true)
222+
printf '%s\n' "${out}" | grep -E '^[0-9]+\.' | head -1 || true
222223
}
223224

224225
# -----------------------------------------------------------------------------

0 commit comments

Comments
 (0)