Commit f14ac52a authored by zudov's avatar zudov Committed by Austin Seipp

Use bracket in `withCurrentDirectory`

Summary: There was a comment about that. Seems like a better behaviour.

Reviewers: austin

Reviewed By: austin

Subscribers: thomie, carter, simonmar

Differential Revision: https://phabricator.haskell.org/D419
parent b0d5b5b3
......@@ -21,6 +21,7 @@ import Distribution.Verbosity
import qualified Distribution.InstalledPackageInfo as Installed
import qualified Distribution.Simple.PackageIndex as PackageIndex
import Control.Exception (bracket)
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.List
......@@ -70,14 +71,10 @@ die :: [String] -> IO a
die errs = do mapM_ (hPutStrLn stderr) errs
exitWith (ExitFailure 1)
-- XXX Should use bracket
withCurrentDirectory :: FilePath -> IO a -> IO a
withCurrentDirectory directory io
= do curDirectory <- getCurrentDirectory
setCurrentDirectory directory
r <- io
setCurrentDirectory curDirectory
return r
= bracket (getCurrentDirectory) (setCurrentDirectory)
(const (setCurrentDirectory directory >> io))
-- We need to use the autoconfUserHooks, as the packages that use
-- configure can create a .buildinfo file, and we need any info that
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment