Skip to content

Commit

Permalink
Merge pull request jgm#1674 from freiric/master
Browse files Browse the repository at this point in the history
fix inDirectory to reset to the original directory in case an exception ...
  • Loading branch information
jgm committed Oct 8, 2014
2 parents 2eaa0f6 + 2423162 commit 8b60d43
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/Text/Pandoc/Shared.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down

0 comments on commit 8b60d43

Please sign in to comment.