fix:journal:include: relative includes from a symlinked file work again [#2503]

This commit is contained in:
Simon Michael 2025-12-08 09:36:13 -10:00
parent 784bdb4637
commit 665e2d0a55
2 changed files with 6 additions and 6 deletions

View File

@ -319,7 +319,7 @@ includedirectivep iopts = do
) <|> errorNoArg
let (mprefix,glb) = splitReaderPrefix prefixedglob
parentf <- sourcePosFilePath pos -- a little slow, don't do too often
parentf <- sourcePosFilePath pos
when (null $ dbg6 (parentf <> " include: glob pattern") glb) errorNoArg
-- Find the file or glob-matched files (just the ones from this include directive), with some IO error checking.
@ -379,7 +379,8 @@ includedirectivep iopts = do
expandedglob <- lift $ expandHomePath globpattern & handleIOError off "failed to expand ~"
-- get the directory of the including file
let cwd = takeDirectory parentf
-- need to canonicalise a symlink parentf so takeDirectory works correctly [#2503]
cwd <- fmap takeDirectory <$> liftIO $ canonicalizePath parentf
-- Don't allow 3 or more stars.
when ("***" `isInfixOf` expandedglob) $

View File

@ -177,7 +177,6 @@ $ touch /tmp/unreadable.$$ && chmod -r /tmp/unreadable.$$ && hledger -f /tmp/un
#
# My ~/.hledger.journal is a symlink to .etc/.hledger.journal
# ** 21. But I did find this possibly related regression in 1.50.4 & 1.51:
# Failing test:
# $ hledger -f symlink-to-relative-include.j files
# > //
# ** 21. But I did find this possibly related regression in 1.50.4 & 1.51 [#2503].
$ hledger -f symlink-to-relative-include.j files
> //