
#7962: "ghc -e <invalid expression>" should return non-zero exit status ----------------------------+----------------------------------------------- Reporter: timmaxw | Owner: Type: feature request | Status: new Priority: normal | Component: GHCi Version: 7.6.2 | Keywords: Os: Linux | Architecture: Unknown/Multiple Failure: Other | Blockedby: Blocking: | Related: ----------------------------+----------------------------------------------- Changes (by timmaxw): * cc: timmaxw@… (added) Comment: GHC exits with status 1 if it encounters errors when compiling: {{{ $ cat >Test.hs askfljawioefjaiwojfeoawfe $ ghc Test.hs [1 of 1] Compiling Main ( Test.hs, Test.o ) Test.hs:1:1: Parse error: naked expression at top level $ echo $? 1 }}} It also exits with status 1 if the expression passed to "ghc -e" evaluates to bottom: {{{ $ ghc -e "head []" <interactive>: Prelude.head: empty list $ echo $? 1 }}} It seems odd that GHC would return 1 in both of those cases, but return 0 for "ghc -e <invalid expression>". Either the return value in one or both of those cases should be changed to 0, or the return value for "ghc -e <invalid expression>" should be changed to 1. "runghc" behaves like a call to "ghc -e main <some file>". If there is an error in the expression "main" (i.e. if "main" is not in scope) it returns 0: {{{ $ cat >Test2.hs foo = 1 $ runghc Test2.hs Test2.hs:1:33: Not in scope: `main' Perhaps you meant `min' (imported from Prelude) $ echo $? 0 }}} But if there is an error in the text of the program itself, or if the program throws an exception when "main" is run, then it returns 1. -- Ticket URL: http://hackage.haskell.org/trac/ghc/ticket/7962#comment:3 GHC http://www.haskell.org/ghc/ The Glasgow Haskell Compiler