;imp:lib:Hledger.Utils.IO.expandHomePath: handle a bare ~

This commit is contained in:
Simon Michael 2025-12-24 17:12:24 -10:00
parent de900e5b24
commit 60293349bb

View File

@ -401,6 +401,7 @@ getHomeSafe = fmap Just getHomeDirectory `catch` (\(_ :: IOException) -> return
-- ~username is not supported. Can raise an error.
expandHomePath :: FilePath -> IO FilePath
expandHomePath = \case
"~" -> getHomeDirectory
('~':'/':p) -> (</> p) <$> getHomeDirectory
('~':'\\':p) -> (</> p) <$> getHomeDirectory
('~':_) -> ioError $ userError "~USERNAME in paths is not supported"