add
This commit is contained in:
parent
cb0f435d94
commit
fd61354431
1 changed files with 22 additions and 0 deletions
22
Utility/Network.hs
Normal file
22
Utility/Network.hs
Normal file
|
@ -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"]
|
Loading…
Add table
Reference in a new issue