diff options
author | John MacFarlane <jgm@berkeley.edu> | 2014-10-08 15:48:59 -0700 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2014-10-08 15:48:59 -0700 |
commit | 8b60d430f2095c42daf26f2921359d5c49f0757d (patch) | |
tree | cc6971239704120fd1c261c7d9eab1a1d2e05468 /src/Text | |
parent | 2eaa0f6ab168bf9ebb97ee39949d4935cc5faef0 (diff) | |
parent | 24231623f3e2e44d3035ced7e971f3491f705e46 (diff) | |
download | pandoc-8b60d430f2095c42daf26f2921359d5c49f0757d.tar.gz |
Merge pull request #1674 from freiric/master
fix inDirectory to reset to the original directory in case an exception ...
Diffstat (limited to 'src/Text')
-rw-r--r-- | src/Text/Pandoc/Shared.hs | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/src/Text/Pandoc/Shared.hs b/src/Text/Pandoc/Shared.hs index 6e1f84335..9aa70e6f2 100644 --- a/src/Text/Pandoc/Shared.hs +++ b/src/Text/Pandoc/Shared.hs @@ -735,12 +735,10 @@ renderTags' = renderTagsOptions -- | Perform an IO action in a directory, returning to starting directory. inDirectory :: FilePath -> IO a -> IO a -inDirectory path action = do - oldDir <- getCurrentDirectory - setCurrentDirectory path - result <- action - setCurrentDirectory oldDir - return result +inDirectory path action = E.bracket + getCurrentDirectory + setCurrentDirectory + (const $ setCurrentDirectory path >> action) readDefaultDataFile :: FilePath -> IO BS.ByteString readDefaultDataFile fname = |