Fix bug in -z handling of trailing NUL in input
The obvious way to fix this would be to adapt lines to split on null. However, it's actually nontrivial to rewrite lines. In particular it has a weird implementation to avoid a space leak. See: https://gitlab.haskell.org/ghc/ghc/-/issues/4334 Also, while that is a small amount of code, it's covered by a rather complex copyright and I'd have to include that copyright in git-annex. So, I opted to filter out the trailing empty string instead. Sponsored-by: Dartmouth College's Datalad project
This commit is contained in:
parent
0184421a4d
commit
c4ad9b1446
4 changed files with 33 additions and 1 deletions
|
@ -115,7 +115,17 @@ batchLines (BatchFormat sep _) = do
|
|||
where
|
||||
splitter = case sep of
|
||||
BatchLine -> lines
|
||||
BatchNull -> splitc '\0'
|
||||
BatchNull -> elimemptyend . splitc '\0'
|
||||
|
||||
-- When there is a trailing null on the input, eliminate the empty
|
||||
-- string that splitc generates. Other empty strings elsewhere in
|
||||
-- the list are preserved. This is the same effect as how `lines`
|
||||
-- handles a trailing newline.
|
||||
elimemptyend [] = []
|
||||
elimemptyend (x:[])
|
||||
| null x = []
|
||||
| otherwise = [x]
|
||||
elimemptyend (x:rest) = x : elimemptyend rest
|
||||
|
||||
-- When concurrency is enabled at the command line, it is used in batch
|
||||
-- mode. But, if it's only set in git config, don't use it, because the
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue