From 3940f2cbde7a7ca220be932abb58f1c1a99c9b26 Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Sun, 30 Mar 2014 01:17:19 -0400 Subject: use fqdn --- HostName.hs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'HostName.hs') diff --git a/HostName.hs b/HostName.hs index dfe9efb4..2cc50ea9 100644 --- a/HostName.hs +++ b/HostName.hs @@ -1,10 +1,9 @@ module HostName where -import Data.Maybe import Control.Applicative import System.Environment -import qualified Utility.Network as Network +import Utility.Process type HostName = String @@ -12,5 +11,8 @@ getHostName :: IO HostName getHostName = go =<< getArgs where go (h:_) = return h - go [] = fromMaybe nohostname <$> Network.getHostname - nohostname = error "Cannot determine hostname! Pass it on the command line." + go [] = do + s <- takeWhile (/= '\n') <$> readProcess "hostname" ["-f"] + if null s + then error "Cannot determine hostname! Pass it on the command line." + else return s -- cgit v1.2.3