Revision 30d25dd8 htools/htools.hs
b/htools/htools.hs | ||
---|---|---|
25 | 25 |
|
26 | 26 |
module Main (main) where |
27 | 27 |
|
28 |
import Control.Exception |
|
29 |
import Control.Monad (guard) |
|
28 | 30 |
import Data.Char (toLower) |
31 |
import Prelude hiding (catch) |
|
29 | 32 |
import System.Environment |
30 | 33 |
import System.Exit |
31 | 34 |
import System.IO |
35 |
import System.IO.Error (isDoesNotExistError) |
|
32 | 36 |
|
33 | 37 |
import Ganeti.HTools.Utils |
34 | 38 |
import Ganeti.HTools.CLI (parseOpts) |
... | ... | |
47 | 51 |
|
48 | 52 |
main :: IO () |
49 | 53 |
main = do |
50 |
binary <- getEnv "HTOOLS" `catch` const getProgName |
|
54 |
binary <- catchJust (guard . isDoesNotExistError) |
|
55 |
(getEnv "HTOOLS") (const getProgName) |
|
51 | 56 |
let name = map toLower binary |
52 | 57 |
boolnames = map (\(x, y) -> (x == name, Just y)) personalities |
53 | 58 |
case select Nothing boolnames of |
Also available in: Unified diff