From 4d6c918eff325adffbf5a02b72a7d371fb2e78ef Mon Sep 17 00:00:00 2001 From: Joey Hess Date: Wed, 26 Apr 2023 00:12:38 -0400 Subject: [PATCH] avoid quoting spaces in git-annex find output to terminal That's too much quoting, the user expects the filename to be copy and pasteable. It would be ok to slash-escape space ('\ ') which is what gnu find does, but it doesn't seem necessary either. ${escaped_file} has always quoted spaces though, so keep on doing it there. Sponsored-by: Nicholas Golder-Manning on Patreon --- CHANGELOG | 2 +- Command/Find.hs | 2 +- doc/git-annex-examinekey.mdwn | 2 +- doc/git-annex-find.mdwn | 4 ++-- doc/git-annex-findkeys.mdwn | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 5bd772ff73..b75a61bf55 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -10,7 +10,7 @@ git-annex (10.20230408) UNRELEASED; urgency=medium control characters are only filtered out when displaying to the terminal. * find, findkeys, examinekey: When outputting to a terminal and --format - is not used, quote unusual characters. + is not used, quote control characters. Output to a pipe is unchanged. (Similar to the behavior of GNU find.) * addurl --preserve-filename now rejects filenames that contain other control characters, besides the escape sequences it already rejected. diff --git a/Command/Find.hs b/Command/Find.hs index 21e2a56bd2..d5971e3875 100644 --- a/Command/Find.hs +++ b/Command/Find.hs @@ -105,7 +105,7 @@ showFormatted (IsTerminal isterminal) format unformatted vars = case format of Nothing -> do liftIO $ S8.putStrLn $ if isterminal - then Utility.Format.escapedFormat unformatted + then Utility.Format.encode_c (const False) unformatted else unformatted Just formatter -> liftIO $ putStr $ Utility.Format.format formatter $ diff --git a/doc/git-annex-examinekey.mdwn b/doc/git-annex-examinekey.mdwn index 4c3e1b304c..b1f714ff56 100644 --- a/doc/git-annex-examinekey.mdwn +++ b/doc/git-annex-examinekey.mdwn @@ -35,7 +35,7 @@ that can be determined purely by looking at the key. Also, '\\n' is a newline, '\\000' is a NULL, etc. The default output format is the same as `--format='${escapedkey}\\n'` - when outputting to the terminal, and otherwise `--format='${key}\\n'` + except when outputting to a terminal, control characters will be escaped. * `--json` diff --git a/doc/git-annex-find.mdwn b/doc/git-annex-find.mdwn index 7a667d4672..d2acbd2d4d 100644 --- a/doc/git-annex-find.mdwn +++ b/doc/git-annex-find.mdwn @@ -50,8 +50,8 @@ finds files in the current directory and its subdirectories. Also, '\\n' is a newline, '\\000' is a NULL, etc. - The default output format is the same as `--format='${escaped_file}\\n'` - when outputting to the terminal, and otherwise `--format='${file}\\n'` + The default output format is the same as `--format='${file}\\n'`, + except when outputting to a terminal, control characters will be escaped. * `--json` diff --git a/doc/git-annex-findkeys.mdwn b/doc/git-annex-findkeys.mdwn index ac1b16d067..6be8a816bf 100644 --- a/doc/git-annex-findkeys.mdwn +++ b/doc/git-annex-findkeys.mdwn @@ -46,7 +46,7 @@ Outputs a list of keys known to git-annex. Also, '\\n' is a newline, '\\000' is a NULL, etc. The default output format is the same as `--format='${escapedkey}\\n'` - when outputting to the terminal, and otherwise `--format='${key}\\n'` + except when outputting to a terminal, control characters will be escaped. * `--json`