diff options
author | Joey Hess <joey@kitenet.net> | 2012-08-05 14:50:00 -0400 |
---|---|---|
committer | Joey Hess <joey@kitenet.net> | 2012-08-05 14:50:00 -0400 |
commit | fd61354431c0ee59e8adf6d026e14f0c718bd33b (patch) | |
tree | 2d651c0e4173482e44059735b3b7e9fa8b297381 /Utility | |
parent | cb0f435d948a597429db5e51f2b3d2b15294090f (diff) |
add
Diffstat (limited to 'Utility')
-rw-r--r-- | Utility/Network.hs | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/Utility/Network.hs b/Utility/Network.hs new file mode 100644 index 000000000..bedb37dc9 --- /dev/null +++ b/Utility/Network.hs @@ -0,0 +1,22 @@ +{- network functions + - + - Copyright 2012 Joey Hess <joey@kitenet.net> + - + - Licensed under the GNU GPL version 3 or higher. + -} + +module Utility.Network where + +import Utility.Process +import Utility.Exception + +import Control.Applicative + +{- Haskell lacks uname(2) bindings, except in the + - Bindings.Uname addon. Rather than depend on that, + - use uname -n when available. -} +getHostname :: IO (Maybe String) +getHostname = catchMaybeIO uname_node + where + uname_node = takeWhile (/= '\n') <$> + readProcess "uname" ["-n"] |