From 59d110e0a86ffed5872b5a59c6b31f2e4377f00c Mon Sep 17 00:00:00 2001 From: Simon Michael Date: Sat, 17 Jan 2009 19:23:21 +0000 Subject: [PATCH] fix reading from stdin, except for ui command --- hledger.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hledger.hs b/hledger.hs index df0301272..faabbee70 100644 --- a/hledger.hs +++ b/hledger.hs @@ -76,8 +76,10 @@ main = do parseLedgerAndDo :: [Opt] -> [String] -> ([Opt] -> [String] -> Ledger -> IO ()) -> IO () parseLedgerAndDo opts args cmd = do refdate <- today - -- ack, we're reading the file twice in order to save the text f <- ledgerFilePathFromOpts opts - rawtext <- readFile f + -- XXX we read the file twice - inelegant + -- and, doesn't work with stdin. kludge it, stdin won't work with ui command + let f' = if f == "-" then "/dev/null" else f + rawtext <- readFile f' let runcmd = cmd opts args . prepareLedger opts args refdate rawtext return f >>= runErrorT . parseLedgerFile >>= either (hPutStrLn stderr) runcmd