git.iko.soy/typeable/pandoc
on master help sign in
Merge pull request #1674 from freiric/master

fix inDirectory to reset to the original directory in case an exception ...

commit8b60d430f2095c42daf26f2921359d5c49f0757d authorJohn MacFarlane <jgm@berkeley.edu> dateWed 8 Oct 2014, 15:48 (12 years ago) parent2eaa0f62423162
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 =