
Hi, In src/prelude/System/SystemFun.hs the OS's system function is called to implement System.system. However, the various checks are not done and WEXITSTATUS is not applied as appropriate. It looks like src/runtime/Builtin/cSystem.c does the same thing. src/libraries/base/System/Cmd.hs uses systemCmd when __GLASGOW_HASKELL__ is defined, which is defined in libraries/base/cbits/system.c. This looks like it is doing the right stuff. This causes this: -----8<----------8<----------8<----------8<----- main :: IO () main = mapM_ f [0..5] f :: Int -> IO () f i = do x <- system $ "exit " ++ show i print x -----8<----------8<----------8<----------8<----- to output this for me: ExitSuccess ExitFailure 256 ExitFailure 512 ExitFailure 768 ExitFailure 1024 ExitFailure 1280 Thanks Ian

Ian Lynagh
In src/prelude/System/SystemFun.hs the OS's system function is called to implement System.system. However, the various checks are not done and WEXITSTATUS is not applied as appropriate.
main = mapM_ f [0..5]
f :: Int -> IO () f i = do x <- system $ "exit " ++ show i print x -----8<----------8<----------8<----------8<----- ExitSuccess ExitFailure 256 ExitFailure 512 ExitFailure 768 ExitFailure 1024 ExitFailure 1280
Thanks for the bug report. This has been noticed before. However, the Haskell'98 Libraries Report states simply that: "Computation /system cmd/ returns the exit code produced when the operating system processes the command /cmd/". and "The exact interpretation of [exit] /code/ is operating system dependent". It does not define any particular mapping of ExitFailure codes, and in particular it makes no mention of any unix shell. nhc98 directly passes on the exit status provided by the operating system call 'system()', whereas ghc converts that value into the equivalent value that would be seen in some shells. As far as I can see, both behaviours are permitted. Nonetheless, this is an unfortunate incompatibility between compilers, so probably worth changing. Regards, Malcolm
participants (2)
-
Ian Lynagh
-
Malcolm Wallace