summaryrefslogtreecommitdiff
path: root/HostName.hs
diff options
context:
space:
mode:
authorJoey Hess2014-03-30 01:17:19 -0400
committerJoey Hess2014-03-30 01:17:19 -0400
commit3940f2cbde7a7ca220be932abb58f1c1a99c9b26 (patch)
tree0b4b31ce29161e1adcfdb1087b5dfd08bb9f7691 /HostName.hs
parent8684db8bbf886d5dc41523e2b79df54aa1702cf8 (diff)
use fqdn
Diffstat (limited to 'HostName.hs')
-rw-r--r--HostName.hs10
1 files changed, 6 insertions, 4 deletions
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