find, findkeys, examinekey: escape output to terminal when --format is not used

Note that filenames are not quoted, only escaped. This is to match the
output of --format with escaping.

Sponsored-by: Lawrence Brogan on Patreon
This commit is contained in:
Joey Hess 2023-04-11 14:57:09 -04:00
parent df6f9f1ee8
commit afa5b883dc
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
10 changed files with 85 additions and 28 deletions

View file

@ -5,6 +5,8 @@
- Licensed under the GNU AGPL version 3 or higher.
-}
{-# LANGUAGE OverloadedStrings #-}
module Command.ExamineKey where
import Command
@ -14,6 +16,7 @@ import Annex.Link
import Backend
import Types.Backend
import Types.Key
import Utility.SafeOutput
import Data.Char
import qualified Data.ByteString as B
@ -54,7 +57,8 @@ run o _ input = do
objectpath <- calcRepo $ gitAnnexLocation k
let objectpointer = formatPointer k
showFormatted (format o) (serializeKey' k) $
isterminal <- liftIO $ checkIsTerminal stdout
showFormatted isterminal (format o) (serializeKey' k) $
[ ("objectpath", fromRawFilePath objectpath)
, ("objectpointer", fromRawFilePath objectpointer)
] ++ formatVars k af