+# ||: 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)
+case $h in
+ *"no PTR record")
+ echo "error: chost: $h" >&2
+ exit 1
+ ;;
+esac
+h=${h##* }
+# trailing dot in a hostname will mess up rsync
+h=${h%.}
+echo $h