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
|
@ -10,6 +10,8 @@ git-annex (6.20161211) UNRELEASED; urgency=medium
|
||||||
with too many old versions of ssh and unusual ssh configurations.
|
with too many old versions of ssh and unusual ssh configurations.
|
||||||
It should have not been needed anyway since ssh is supposted to
|
It should have not been needed anyway since ssh is supposted to
|
||||||
have TCPKeepAlive enabled by default.
|
have TCPKeepAlive enabled by default.
|
||||||
|
* Make all --batch input, as well as fromkey and registerurl stdin
|
||||||
|
be processed without requiring it to be in the current encoding.
|
||||||
|
|
||||||
-- Joey Hess <id@joeyh.name> Sun, 11 Dec 2016 21:29:51 -0400
|
-- Joey Hess <id@joeyh.name> Sun, 11 Dec 2016 21:29:51 -0400
|
||||||
|
|
||||||
|
|
|
@ -48,16 +48,19 @@ batchBadInput Batch = liftIO $ putStrLn ""
|
||||||
|
|
||||||
-- Reads lines of batch mode input and passes to the action to handle.
|
-- Reads lines of batch mode input and passes to the action to handle.
|
||||||
batchInput :: (String -> Either String a) -> (a -> Annex ()) -> Annex ()
|
batchInput :: (String -> Either String a) -> (a -> Annex ()) -> Annex ()
|
||||||
batchInput parser a = do
|
batchInput parser a = go =<< batchLines
|
||||||
mp <- liftIO $ catchMaybeIO getLine
|
|
||||||
case mp of
|
|
||||||
Nothing -> return ()
|
|
||||||
Just v -> do
|
|
||||||
either parseerr a (parser v)
|
|
||||||
batchInput parser a
|
|
||||||
where
|
where
|
||||||
|
go [] = return ()
|
||||||
|
go (l:rest) = do
|
||||||
|
either parseerr a (parser l)
|
||||||
|
go rest
|
||||||
parseerr s = giveup $ "Batch input parse failure: " ++ s
|
parseerr s = giveup $ "Batch input parse failure: " ++ s
|
||||||
|
|
||||||
|
batchLines :: Annex [String]
|
||||||
|
batchLines = liftIO $ do
|
||||||
|
fileEncoding stdin
|
||||||
|
lines <$> getContents
|
||||||
|
|
||||||
-- Runs a CommandStart in batch mode.
|
-- Runs a CommandStart in batch mode.
|
||||||
--
|
--
|
||||||
-- The batch mode user expects to read a line of output, and it's up to the
|
-- The batch mode user expects to read a line of output, and it's up to the
|
||||||
|
|
|
@ -45,7 +45,7 @@ startMass = do
|
||||||
next massAdd
|
next massAdd
|
||||||
|
|
||||||
massAdd :: CommandPerform
|
massAdd :: CommandPerform
|
||||||
massAdd = go True =<< map (separate (== ' ')) . lines <$> liftIO getContents
|
massAdd = go True =<< map (separate (== ' ')) <$> batchLines
|
||||||
where
|
where
|
||||||
go status [] = next $ return status
|
go status [] = next $ return status
|
||||||
go status ((keyname,f):rest) | not (null keyname) && not (null f) = do
|
go status ((keyname,f):rest) | not (null keyname) && not (null f) = do
|
||||||
|
|
|
@ -35,7 +35,7 @@ start [] = do
|
||||||
start _ = giveup "specify a key and an url"
|
start _ = giveup "specify a key and an url"
|
||||||
|
|
||||||
massAdd :: CommandPerform
|
massAdd :: CommandPerform
|
||||||
massAdd = go True =<< map (separate (== ' ')) . lines <$> liftIO getContents
|
massAdd = go True =<< map (separate (== ' ')) <$> batchLines
|
||||||
where
|
where
|
||||||
go status [] = next $ return status
|
go status [] = next $ return status
|
||||||
go status ((keyname,u):rest) | not (null keyname) && not (null u) = do
|
go status ((keyname,u):rest) | not (null keyname) && not (null u) = do
|
||||||
|
|
|
@ -32,3 +32,7 @@ Note that this is indeed valid utf-8:
|
||||||
00000000 c3 a9 0a |...|
|
00000000 c3 a9 0a |...|
|
||||||
00000003
|
00000003
|
||||||
"""]]
|
"""]]
|
||||||
|
|
||||||
|
> Despite my strange inability to reproduce these, there's really only one
|
||||||
|
> thing that can fix it, namely using fileEncoding. Now done for all batch
|
||||||
|
> and stdin reading stuff. [[fixed|done]] I suppose. --[[Joey]]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue