T.P.App.Opt: fix logic bug in fullDefaultsPath.

Previously we would (also) search the default user data directory
for a defaults file, even if a different user data directory
was specified using `--data-dir`.  This was a mistake; if
`--data-dir` is used, the default user data directory should
not be searched.
This commit is contained in:
John MacFarlane 2022-01-17 19:53:26 -08:00
parent a92ae0a58a
commit 545c0911aa

View file

@ -707,9 +707,10 @@ fullDefaultsPath dataDir file = do
let fp = if null (takeExtension file)
then addExtension file "yaml"
else file
defaultDataDir <- liftIO defaultUserDataDir
let defaultFp = fromMaybe defaultDataDir dataDir </> "defaults" </> fp
fromMaybe fp <$> findM fileExists [fp, defaultFp]
let searchpath = fp : case dataDir of
Nothing -> []
Just d -> [d </> "defaults" </> fp]
fromMaybe fp <$> findM fileExists searchpath
-- | In a list of lists, append another list in front of every list which
-- starts with specific element.