]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Fix host and dig erroring to stdout.
authorRoy Marples <roy@marples.name>
Mon, 21 Apr 2008 23:11:07 +0000 (23:11 +0000)
committerRoy Marples <roy@marples.name>
Mon, 21 Apr 2008 23:11:07 +0000 (23:11 +0000)
dhcpcd.sh.in

index 9b3cb4157101e512939f59b4ba3ae57679b16104..5915d00c636beef25929144ec2651130b7b6da23 100644 (file)
@@ -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()