From: simonmar Date: Wed, 1 Sep 2004 09:43:25 +0000 (+0000) Subject: [project @ 2004-09-01 09:43:25 by simonmar] X-Git-Tag: Initial_conversion_from_CVS_complete~1654 X-Git-Url: http://git.megacz.com/?a=commitdiff_plain;h=a8f00cda6b77735e90d282dd1bb0c70ed299fdc9;hp=d1f512dc5379536f0b75ab7e7be5933d0226b0ec;p=ghc-hetmet.git [project @ 2004-09-01 09:43:25 by simonmar] Catch exit(127) result from raw system, and report that we couldn't execute the program. This is a semi-hack; all exec() errors get reported as exit(127) by rawSystem, but if we treat it just like a program that does exit(127) then the user sees no output. --- diff --git a/ghc/compiler/main/SysTools.lhs b/ghc/compiler/main/SysTools.lhs index a2dae88..f673c98 100644 --- a/ghc/compiler/main/SysTools.lhs +++ b/ghc/compiler/main/SysTools.lhs @@ -741,9 +741,18 @@ runSomething phase_name pgm args = do let real_args = filter notNull (map showOpt args) traceCmd phase_name (unwords (pgm:real_args)) $ do exit_code <- rawSystem pgm real_args - if (exit_code /= ExitSuccess) - then throwDyn (PhaseFailed phase_name exit_code) - else return () + case exit_code of + ExitSuccess -> + return () + -- rawSystem returns (ExitFailure 127) if the exec failed for any + -- reason (eg. the program doesn't exist). This is the only clue + -- we have, but we need to report something to the user because in + -- the case of a missing program there will otherwise be no output + -- at all. + ExitFailure 127 -> + throwDyn (InstallationError ("could not execute: " ++ pgm)) + ExitFailure _other -> + throwDyn (PhaseFailed phase_name exit_code) traceCmd :: String -> String -> IO () -> IO () -- a) trace the command (at two levels of verbosity)