Make all --batch input, as well as fromkey and registerurl stdin be processed without requiring it to be in the current encoding.
This commit is contained in:
parent
a12eac060c
commit
469bfa7ff3
5 changed files with 18 additions and 9 deletions
|
@ -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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue