diff options
author | Joey Hess <joeyh@joeyh.name> | 2016-12-13 15:35:04 -0400 |
---|---|---|
committer | Joey Hess <joeyh@joeyh.name> | 2016-12-13 15:35:04 -0400 |
commit | 91546b8c484bf5b40bc9cafcba72679378b2d60a (patch) | |
tree | 86ba4a5d3a977ea579cd3c9c0b97212af81fef79 /CmdLine/Batch.hs | |
parent | 189e261a42020f6980854cfd4e0bcd32941455b5 (diff) |
Make all --batch input, as well as fromkey and registerurl stdin be processed without requiring it to be in the current encoding.
Diffstat (limited to 'CmdLine/Batch.hs')
-rw-r--r-- | CmdLine/Batch.hs | 17 |
1 files changed, 10 insertions, 7 deletions
diff --git a/CmdLine/Batch.hs b/CmdLine/Batch.hs index 627c1df10..6ef21372f 100644 --- a/CmdLine/Batch.hs +++ b/CmdLine/Batch.hs @@ -48,16 +48,19 @@ batchBadInput Batch = liftIO $ putStrLn "" -- Reads lines of batch mode input and passes to the action to handle. batchInput :: (String -> Either String a) -> (a -> Annex ()) -> Annex () -batchInput parser a = do - mp <- liftIO $ catchMaybeIO getLine - case mp of - Nothing -> return () - Just v -> do - either parseerr a (parser v) - batchInput parser a +batchInput parser a = go =<< batchLines where + go [] = return () + go (l:rest) = do + either parseerr a (parser l) + go rest parseerr s = giveup $ "Batch input parse failure: " ++ s +batchLines :: Annex [String] +batchLines = liftIO $ do + fileEncoding stdin + lines <$> getContents + -- Runs a CommandStart in batch mode. -- -- The batch mode user expects to read a line of output, and it's up to the |