filter out control characters and quote filenames
Searched for uses of putStr and hPutStr and changed appropriate ones to filter out control characters and quote filenames. This notably does not make find and findkeys quote filenames in their default output. Because they should only do that when stdout is non a pipe. A few commands like calckey and lookupkey seem too low-level to make sense to filter output, so skipped those. Also when relaying output from other commands that is not progress output, have git-annex filter out control characters. Sponsored-by: k0ld on Patreon
This commit is contained in:
parent
11e89c5a29
commit
df6f9f1ee8
15 changed files with 75 additions and 39 deletions
|
@ -5,6 +5,8 @@
|
|||
- Licensed under the GNU AGPL version 3 or higher.
|
||||
-}
|
||||
|
||||
{-# LANGUAGE OverloadedStrings #-}
|
||||
|
||||
module Command.Log where
|
||||
|
||||
import qualified Data.Set as S
|
||||
|
@ -12,6 +14,7 @@ import qualified Data.Map as M
|
|||
import Data.Char
|
||||
import Data.Time.Clock.POSIX
|
||||
import Data.Time
|
||||
import qualified Data.ByteString.Char8 as B8
|
||||
import qualified System.FilePath.ByteString as P
|
||||
|
||||
import Command
|
||||
|
@ -166,15 +169,17 @@ mkOutputter m zone o file
|
|||
lookupdescription u = maybe (fromUUID u) (fromUUIDDesc) (M.lookup u m)
|
||||
|
||||
normalOutput :: (UUID -> String) -> FilePath -> (POSIXTime -> String) -> Outputter
|
||||
normalOutput lookupdescription file formattime logchange ts us =
|
||||
liftIO $ mapM_ (putStrLn . format) us
|
||||
normalOutput lookupdescription file formattime logchange ts us = do
|
||||
qp <- coreQuotePath <$> Annex.getGitConfig
|
||||
liftIO $ mapM_ (B8.putStrLn . quote qp . format) us
|
||||
where
|
||||
time = formattime ts
|
||||
addel = case logchange of
|
||||
Added -> "+"
|
||||
Removed -> "-"
|
||||
format u = unwords [ addel, time, file, "|",
|
||||
fromUUID u ++ " -- " ++ lookupdescription u ]
|
||||
format u = UnquotedString addel <> " " <> UnquotedString time <> " "
|
||||
<> QuotedPath (toRawFilePath file) <> " | " <> UnquotedByteString (fromUUID u)
|
||||
<> " -- " <> UnquotedString (lookupdescription u)
|
||||
|
||||
gourceOutput :: (UUID -> String) -> FilePath -> Outputter
|
||||
gourceOutput lookupdescription file logchange ts us =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue