Re: System.system
Malcolm Wallace <[email protected]> Wed, 11 Feb 2004 12:07:00 +0000
| Newsgroups | gmane.comp.lang.haskell.nhc.bugs |
|---|---|
| Organization | Dept of Computer Science, University of York |
| Message-ID | <[email protected]> |
Ian Lynagh <[email protected]> writes: > 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