X-Git-Url: https://iankelling.org/git/?a=blobdiff_plain;f=chost;h=a26529fee9efbeaf3a14632946d59d4e84d7bc8d;hb=431d05933ceffb3a314775ee3dcb13b6c6bcb699;hp=3e1acd216f8cf5fe055641021c95844f7f53b070;hpb=f74458d51ebaeba827307920c7a66ed2d69d6fbd;p=automated-distro-installer diff --git a/chost b/chost index 3e1acd2..a26529f 100755 --- a/chost +++ b/chost @@ -7,7 +7,9 @@ set -eE -o pipefail trap 'echo "$0:$LINENO:error: \"$BASH_COMMAND\" returned $?" >&2' ERR host=$1 -addr=$(host $host | sed -rn 's/^.*has address (.*)/\1/p;T;q') +# ||: because if we are using 2+ resolvers, 1 may fail, causing error, but we still get +# a valid address and we just use that +addr=$(host $host | sed -rn 's/^\S+ has address //p;T;q' ||:) h=$(host $addr) h=${h##* } -echo ${h%%.*} +echo $h