git.iko.soy/typeable/pandoc
on master help sign in
fix inDirectory to reset to the original directory in case an exception occurs
commit24231623f3e2e44d3035ced7e971f3491f705e46 authorFreiric Barral <freiric@gmail.com> dateWed 8 Oct 2014, 23:25 (12 years ago) parentd60707e
1 file changed+4−6
src/Text/Pandoc/Shared.hs+4−6
src/Text/Pandoc/Shared.hs+4−6
@@ -735,12 +735,10 @@ renderTags' = renderTagsOptions
735735
736736-- | Perform an IO action in a directory, returning to starting directory.
737737inDirectory :: FilePath -> IO a -> IO a
738−inDirectory path action = do
739− oldDir <- getCurrentDirectory
740− setCurrentDirectory path
741− result <- action
742− setCurrentDirectory oldDir
743− return result
738+inDirectory path action = E.bracket
739+ getCurrentDirectory
740+ setCurrentDirectory
741+ (const $ setCurrentDirectory path >> action)
744742
745743readDefaultDataFile :: FilePath -> IO BS.ByteString
746744readDefaultDataFile fname =