From f2c1586238dc276f43fd5213b1a86e39f8d8c9b0 Mon Sep 17 00:00:00 2001 From: Joseph Weston Date: Tue, 24 Jul 2018 22:05:38 +0200 Subject: [PATCH] lib: sort the matched include files lexicographically Now the files are included in the same order as they would be listed by 'ls'. --- hledger-lib/Hledger/Read/JournalReader.hs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/hledger-lib/Hledger/Read/JournalReader.hs b/hledger-lib/Hledger/Read/JournalReader.hs index d72454d4f..d2eb7b6da 100644 --- a/hledger-lib/Hledger/Read/JournalReader.hs +++ b/hledger-lib/Hledger/Read/JournalReader.hs @@ -208,8 +208,9 @@ includedirectivep = do fileglob <- case tryCompileWith compDefault{errorRecovery=False} filename of Right x -> pure x Left e -> parseErrorAt parserpos $ "Invalid glob pattern: " ++ e - -- Get all matching files in the current working directory - filepaths <- liftIO $ globDir1 fileglob curdir + -- Get all matching files in the current working directory, sorting in + -- lexicographic order to simulate the output of 'ls'. + filepaths <- liftIO $ sort <$> globDir1 fileglob curdir if (not . null) filepaths then pure filepaths else parseErrorAt parserpos$ "No existing files match pattern: " ++ filename