From 8cbe4c600327ab3c6879469b09d06ed45f97775f Mon Sep 17 00:00:00 2001 From: Caleb Maclennan Date: Tue, 30 Sep 2025 20:14:52 -0600 Subject: [PATCH] fix: Escape special symbols when passing arguments to addons --- hledger/Hledger/Cli.hs | 4 ++-- hledger/Hledger/Cli/Commands/Run.hs | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/hledger/Hledger/Cli.hs b/hledger/Hledger/Cli.hs index 407582e31..6ca77e935 100644 --- a/hledger/Hledger/Cli.hs +++ b/hledger/Hledger/Cli.hs @@ -452,9 +452,9 @@ main = handleExit $ withGhcDebug' $ do let addonargs0 = filter (/="--") $ supportedgenargsfromconf <> confcmdargs <> cliargswithoutcmd addonargs = dropCliSpecificOpts addonargs0 - shellcmd = printf "%s-%s %s" progname cmdname (unwords' addonargs) :: String + shellcmd = printf "%s-%s %s" progname cmdname (unwords $ map quoteForCommandLine addonargs) :: String dbgio "addon command selected" cmdname - dbgio "addon command arguments after removing cli-specific opts" (map quoteIfNeeded addonargs) + dbgio "addon command arguments" addonargs dbg1IO "running addon" shellcmd system shellcmd >>= exitWith diff --git a/hledger/Hledger/Cli/Commands/Run.hs b/hledger/Hledger/Cli/Commands/Run.hs index 286f0f80b..9a0c21a9c 100644 --- a/hledger/Hledger/Cli/Commands/Run.hs +++ b/hledger/Hledger/Cli/Commands/Run.hs @@ -160,7 +160,7 @@ runCommand defaultJournalOverride findBuiltinCommand addons cmdline = do then run (Just jpaths) findBuiltinCommand addons opts else cmdaction opts j Nothing | cmdname `elem` addons -> - system (printf "%s-%s %s" progname cmdname (unwords' args)) >>= exitWith + system (printf "%s-%s %s" progname cmdname (unwords $ map quoteForCommandLine args)) >>= exitWith Nothing -> error' $ "Unrecognized command: " ++ unwords (cmdname:args) [] -> return ()