{-# OPTIONS -#include "hschooks.h" #-}
-----------------------------------------------------------------------------
--- $Id: DriverFlags.hs,v 1.56 2001/05/31 11:32:25 simonmar Exp $
+-- $Id: DriverFlags.hs,v 1.57 2001/06/13 15:50:25 rrt Exp $
--
-- Driver flags
--
import DriverState
import DriverUtil
-import TmpFiles ( v_TmpDir, kludgedSystem )
+import TmpFiles ( v_TmpDir )
import CmdLineOpts
import Config
import Util
unless n $ do
-- and run it!
- exit_code <- kludgedSystem cmd phase_name
+ exit_code <- system cmd
if exit_code /= ExitSuccess
then throwDyn (PhaseFailed phase_name exit_code)
-----------------------------------------------------------------------------
--- $Id: TmpFiles.hs,v 1.21 2001/05/29 17:53:59 sof Exp $
+-- $Id: TmpFiles.hs,v 1.22 2001/06/13 15:50:25 rrt Exp $
--
-- Temporary file management
--
newTempName, -- :: Suffix -> IO FilePath
addFilesToClean, -- :: [FilePath] -> IO ()
removeTmpFiles, -- :: Int -> [FilePath] -> IO ()
- v_TmpDir,
- kludgedSystem
+ v_TmpDir
) where
-- main
(do when verbose (hPutStrLn stderr ("Removing: " ++ f))
if '*' `elem` f
#if defined(mingw32_TARGET_OS) && defined(MINIMAL_UNIX_DEPS)
- then kludgedSystem (unwords [cRM, dosifyPath f]) "Cleaning temp files" >> return ()
+ then system (unwords [cRM, dosifyPath f]) >> return ()
#else
- then kludgedSystem (unwords [cRM, f]) "Cleaning temp files" >> return ()
+ then system (unwords [cRM, f]) >> return ()
#endif
else removeFile f)
`catchAllIO`
(\_ -> when verbose (hPutStrLn stderr
("Warning: can't remove tmp file " ++ f)))
mapM_ blowAway fs
-
-
--- 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
- = do
-#if !defined(mingw32_TARGET_OS) || defined(MINIMAL_UNIX_DEPS)
- -- in the case where we do want to use an MSDOS command shell, we assume
- -- that files and paths have been converted to a form that's
- -- understandable to the command we're invoking.
- exit_code <- system cmd `catchAllIO`
- (\_ -> throwDyn (PhaseFailed phase_name (ExitFailure 1)))
-#else
- pid <- myGetProcessID
- tmp_dir <- readIORef v_TmpDir
- let tmp = tmp_dir++"/sh"++show pid
- h <- openFile tmp WriteMode
- hPutStrLn h cmd
- hClose h
- exit_code <- system ("sh - " ++ tmp) `catchAllIO`
- (\_ -> removeFile tmp >>
- throwDyn (PhaseFailed phase_name (ExitFailure 1)))
- removeFile tmp
-#endif
- return exit_code