Remove circular dependencies created by kludgedSystem.
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
--- $Id: DriverUtil.hs,v 1.12 2000/12/11 12:30:58 rrt Exp $
+-- $Id: DriverUtil.hs,v 1.13 2000/12/11 14:42:21 sewardj Exp $
--
-- Utils for the driver
--
--
-- Utils for the driver
--
#include "HsVersions.h"
import Util
#include "HsVersions.h"
import Util
-import TmpFiles ( newTempName )
import IOExts
import Exception
import IOExts
import Exception
remove_spaces :: String -> String
remove_spaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
remove_spaces :: String -> String
remove_spaces = reverse . dropWhile isSpace . reverse . dropWhile isSpace
-- system that works feasibly under Windows (i.e. passes the command line to sh,
-- because system() under Windows doesn't look at SHELL, and always uses CMD.EXE)
kludgedSystem cmd phase_name
-- system that works feasibly under Windows (i.e. passes the command line to sh,
-- because system() under Windows doesn't look at SHELL, and always uses CMD.EXE)
kludgedSystem cmd phase_name
exit_code <- system cmd `catchAllIO`
(\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
#else
exit_code <- system cmd `catchAllIO`
(\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
#else
- tmp <- newTempName "sh"
+ pid <- myGetProcessID
+ let tmp = "/tmp/sh" ++ show pid
h <- openFile tmp WriteMode
hPutStrLn h cmd
hClose h
exit_code <- system ("sh - " ++ tmp) `catchAllIO`
h <- openFile tmp WriteMode
hPutStrLn h cmd
hClose h
exit_code <- system ("sh - " ++ tmp) `catchAllIO`
- (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
+ (\_ -> removeFile tmp >>
+ throwDyn (PhaseFailed phase_name (ExitFailure 1)))
removeFile tmp
#endif
return exit_code
removeFile tmp
#endif
return exit_code
-----------------------------------------------------------------------------
-----------------------------------------------------------------------------
--- $Id: TmpFiles.hs,v 1.12 2000/12/11 12:30:58 rrt Exp $
+-- $Id: TmpFiles.hs,v 1.13 2000/12/11 14:42:21 sewardj Exp $
--
-- Temporary file management
--
--
-- Temporary file management
--
-- main
import Config
import Util
-- main
import Config
import Util
-import DriverUtil ( kludgedSystem )
-- hslibs
import Exception
-- hslibs
import Exception
add var x = do
xs <- readIORef var
writeIORef var (x:xs)
add var x = do
xs <- readIORef var
writeIORef var (x:xs)