
I have never used the above function you refer to so I am not sure
about it's semantics. However, I have successfully used functions in
System.Process module [1] (fairly standard) to spawn processes and get
their exit codes on Windows.
For example, (javac exits code 2 when provided no arguments)
C:\Documents and Settings\Tim>javac
Usage: javac <options> <source files>
where possible options include:
-g Generate all debugging info
... snip
C:\Documents and Settings\Tim>echo %ERRORLEVEL%
2
C:\Documents and Settings\Tim>ghci
GHCi, version 6.12.1: http://www.haskell.org/ghc/ :? for help
Loading package ghc-prim ... linking ... done.
Loading package integer-gmp ... linking ... done.
Loading package base ... linking ... done.
Loading package ffi-1.0 ... linking ... done.
Prelude> :m System.Process
Prelude System.Process> readProcessWithExitCode "c:\\jdk6\\bin\
\javac.exe" [] ""
(ExitFailure 2,"","Usage: javac <options>
Hello, I have the following code (fragment) I use to wrap execution of various processes in Haskell, in the spirit of Don Stewart's slides about "Scripting in Haskell".
instance MonadExec IO where exec proc args = do (exit, out, err) <- liftIO $ readProcessWithExitCode proc args "" case exit of ExitFailure e -> throwError $ userError ("Fail execution of " ++ program proc args ++ ": " ++ (show e) ++", " ++err) ExitSuccess -> return out
Here is the abridged declaration of MonadExec: class (Monad m) => MonadExec m where exec :: String -> [String] -> m String
The issue I am facing is that readProcessWithExitCode does not seem to return the expected failures. When I run some failing process within windows command shell, I have:
D:\projets\psug-dojo\lags>"d:/Program Files/scala-2.8.0/bin/scalac.bat" -d target\test-classes -classpath target\classes;D:\projets\ psug-dojo\lags\test-lib\specs_2.8.0-1.6.5.jar;D:\projets\psug-dojo\lags\test-lib\scalacheck_2.8.0-1.7.jar;D:\projets\psug-dojo\lags\ test-lib\junit-4.7.jar -d target\test-classes src\test\scala\oqube\lags\LagsTest.scala src\test\scala\oqube\lags\LagsTest.scala:86: error: not found: value beS_== bid.sublists(List(Request(1,2,3))) must beS_==(List(Nil,List(Request(1,2,3)))) ^ one error found
D:\projets\psug-dojo\lags>echo %ERRORLEVEL% 1
D:\projets\psug-dojo\lags>
but wrapping this same process in my "shell", I always got an ExitSuccess.
What am I doing wrong ?
Thanks Arnaud _______________________________________________ Haskell-Cafe mailing list Haskell-C...@haskell.orghttp://www.haskell.org/mailman/listinfo/haskell-cafe