From: Roy Marples Date: Mon, 21 Apr 2008 23:11:07 +0000 (+0000) Subject: Fix host and dig erroring to stdout. X-Git-Tag: v4.0.2~461 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=94aaf2ebac54ca4386493a2e52dd852e23e32521;p=thirdparty%2Fdhcpcd.git Fix host and dig erroring to stdout. --- diff --git a/dhcpcd.sh.in b/dhcpcd.sh.in index 9b3cb415..5915d00c 100644 --- a/dhcpcd.sh.in +++ b/dhcpcd.sh.in @@ -94,14 +94,23 @@ need_hostname() lookup_hostname() { + local h= + # Silly ISC programs love to send error text to stdout if type host >/dev/null 2>&1; then - host "${new_ip_address}" | \ - sed 's/.* domain name pointer \(.*\)./\1/' + h=`host ${new_ip_address}` + if [ $? = 0 ]; then + echo "${h}" \ + | sed 's/.* domain name pointer \(.*\)./\1/' + return 0 + fi elif type dig >/dev/null 2>&1; then - dig +short -x "${new_ip_address}" | sed 's/\.$//' - else - return 1 + h=`dig +short -x ${new_ip_address}` + if [ $? = 0 ]; then + echo "${h}" | sed 's/\.$//' + return 0 + fi fi + return 1 } set_hostname()