From 52da073828d7a7ae08d644e598730b491c344dba Mon Sep 17 00:00:00 2001 From: Joseph Weston Date: Mon, 23 Jul 2018 11:14:47 +0200 Subject: [PATCH] lib: expand current directory separately from filepath We will need the current directory as an absolute path when adding glob patterns in a few commits time. --- hledger-lib/Hledger/Read/JournalReader.hs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index 238f751fc..0210c7efd 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -193,9 +193,11 @@ includedirectivep = do parentpos <- getPosition + curdir <- lift $ expandPath (takeDirectory $ sourceName parentpos) "" + `orRethrowIOError` (show parentpos ++ " locating " ++ filename) + -- correctly handles case when 'filename' is absolute + let filepath = curdir filename -- read child input - let curdir = takeDirectory (sourceName parentpos) - filepath <- lift $ expandPath curdir filename `orRethrowIOError` (show parentpos ++ " locating " ++ filename) childInput <- lift $ readFilePortably filepath `orRethrowIOError` (show parentpos ++ " reading " ++ filepath) -- save parent state