fix: config file: pass only post-cmd and cmd-specific conf opts to addons

This commit is contained in:
Simon Michael 2024-06-24 13:23:41 +01:00
parent 3345adb2fc
commit 0c9b704bcc

View File

@ -242,10 +242,13 @@ main = withGhcDebug' $ do
conf <- getConf conf <- getConf
let let
genargsfromconf = confLookup "general" conf genargsfromconf = confLookup "general" conf
supportedgenargsfromconf = dropUnsupportedOpts effectivemode genargsfromconf supportedgenargsfromconf
| isaddoncmd = []
| otherwise = dropUnsupportedOpts effectivemode genargsfromconf
excludedgenargsfromconf = genargsfromconf \\ supportedgenargsfromconf
cmdargsfromconf = if null cmd then [] else confLookup cmd conf cmdargsfromconf = if null cmd then [] else confLookup cmd conf
dbgIO1 "extra general args from config file" genargsfromconf dbgIO1 "extra general args from config file" genargsfromconf
dbgIO1 "excluded general args from config file not supported by this command" $ genargsfromconf \\ supportedgenargsfromconf dbgIO1 "excluded general args from config file, not supported by this command" excludedgenargsfromconf
dbgIO1 "extra command args from config file" cmdargsfromconf dbgIO1 "extra command args from config file" cmdargsfromconf
--------------------------------------------------------------- ---------------------------------------------------------------
@ -324,14 +327,18 @@ main = withGhcDebug' $ do
-- all other builtin commands - read the journal and if successful run the command with it -- all other builtin commands - read the journal and if successful run the command with it
| otherwise -> withJournalDo opts $ cmdaction opts | otherwise -> withJournalDo opts $ cmdaction opts
-- external addon command found - run it, passing all arguments except the command name. -- external addon command found - run it, passing
-- It will do its own command line parsing and journal reading. -- 1. any cli arguments written after the command name, except "--"
-- 2. and any command-specific opts from the config file.
-- Arguments written before the command name, and general opts from the config file,
-- are not passed since we can't be sure they're supported.
| isaddoncmd -> do | isaddoncmd -> do
let addonargs = cliargsbeforecmd ++ filter (/="--") cliargsaftercmd let
let shellcmd = printf "%s-%s %s" progname cmd (unwords' addonargs) :: String addonargs = cmdargsfromconf <> filter (/="--") cliargsaftercmd
shellcmd = printf "%s-%s %s" progname cmd (unwords' addonargs) :: String
dbgIO "addon command selected" cmd dbgIO "addon command selected" cmd
dbgIO "addon command arguments" (map quoteIfNeeded addonargs) dbgIO "addon command arguments" (map quoteIfNeeded addonargs)
dbgIO1 "running shell command" shellcmd dbgIO1 "running" shellcmd
system shellcmd >>= exitWith system shellcmd >>= exitWith
-- deprecated command found -- deprecated command found