From 5bd9be2189048cb4f9f04c80e3e9bfd018118ebd Mon Sep 17 00:00:00 2001 From: Dmitry Astapov Date: Sun, 23 Feb 2025 12:42:32 +0000 Subject: [PATCH] run: allow "run" to invoke "run" (fixes #2331) --- hledger/Hledger/Cli/Commands/Run.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/hledger/Hledger/Cli/Commands/Run.hs b/hledger/Hledger/Cli/Commands/Run.hs index cacdf75aa..63842ee8b 100644 --- a/hledger/Hledger/Cli/Commands/Run.hs +++ b/hledger/Hledger/Cli/Commands/Run.hs @@ -101,12 +101,14 @@ runCommand findBuiltinCommand cmdline = do case findBuiltinCommand cmdname of Nothing -> putStrLn $ unwords (cmdname:args) Just (cmdmode,cmdaction) -> do + -- Allow "run" to call "run" + let cmdaction' = if cmdname == "run" then run findBuiltinCommand else cmdaction -- Normally expandArgsAt is done by the Cli.hs, but it stops at the first '--', so we need -- to do it here as well to make sure that each command can use @ARGFILEs args' <- expandArgsAt args dbg1IO "runCommand final args" (cmdname,args') opts <- getHledgerCliOpts' cmdmode args' - withJournalCached opts (cmdaction opts) + withJournalCached opts (cmdaction' opts) [] -> return () runREPL :: (String -> Maybe (Mode RawOpts, CliOpts -> Journal -> IO ())) -> IO ()