From 6e286041f6223c6f203e8b5ab81206427d6aa9a0 Mon Sep 17 00:00:00 2001 From: Rnhmjoj Date: Tue, 14 Oct 2014 00:40:42 +0200 Subject: [PATCH] Use portable static path --- main.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/main.hs b/main.hs index a876e5d..a0a567f 100644 --- a/main.hs +++ b/main.hs @@ -5,6 +5,8 @@ import System.Console.CmdArgs import System.Environment (getArgs, withArgs) import Control.Monad (when) +import Paths_alea (getDataFileName) + import Diceware import Random @@ -46,8 +48,9 @@ main = do exec :: Args -> IO () exec opts@Args{..} = do - file <- readFile dictionary' opts <- getProgArgs + defaultDict <- getDataFileName "diceware" + file <- readFile (if null dictionary then defaultDict else dictionary) if interactive then interact (unlines . map (dice file) . lines) else do @@ -60,4 +63,3 @@ exec opts@Args{..} = do dice' x n = readDiceware' (parseDiceware x) n -- default arguments phraseLength' = if phraseLength == 0 then 6 else phraseLength - dictionary' = if null dictionary then "diceware" else dictionary