[GHC] #7962: "ghc -e <invalid expression>" should return non-zero exit status

GHC ghc-devs at haskell.org
Sun Sep 8 01:11:24 CEST 2013


#7962: "ghc -e <invalid expression>" should return non-zero exit status
------------------------------------+------------------------------------
        Reporter:  timmaxw          |            Owner:
            Type:  feature request  |           Status:  new
        Priority:  normal           |        Milestone:
       Component:  GHCi             |          Version:  7.6.2
      Resolution:                   |         Keywords:
Operating System:  Linux            |     Architecture:  Unknown/Multiple
 Type of failure:  Other            |       Difficulty:  Unknown
       Test Case:                   |       Blocked By:
        Blocking:                   |  Related Tickets:
------------------------------------+------------------------------------
Changes (by rwbarton):

 * cc: rwbarton@… (added)
 * difficulty:   => Unknown


Comment:

 I agree with the original report. The man page says "**-e expr** Evaluate
 expr; see for details." (#3351...) If expr doesn't compile, then ghc has
 failed to evaluate it, IMO.

 In reality I can pass arbitrary GHCi commands to `ghc -e` and it will run
 them; but the documentation doesn't say anything about this (either in the
 man page or in the
 [http://www.haskell.org/ghc/docs/7.6.3/html/users_guide/modes.html#eval-
 mode user's guide]).

 Making `ghc -e expr` return 1 on compile error would also be consistent
 with other languages:
 {{{
 rwbarton at adjunction:/tmp$ bash -c if ; echo $?
 bash: -c: line 1: syntax error: unexpected end of file
 1
 rwbarton at adjunction:/tmp$ python -c if ; echo $?
   File "<string>", line 1
     if
      ^
 SyntaxError: invalid syntax
 1
 rwbarton at adjunction:/tmp$ perl -e if ; echo $?
 syntax error at -e line 1, at EOF
 Execution of -e aborted due to compilation errors.
 255
 rwbarton at adjunction:/tmp$ ruby -e if ; echo $?
 -e:1: syntax error, unexpected $end
 1
 rwbarton at adjunction:/tmp$ ghc -e if ; echo $?

 <interactive>:1:3: parse error (possibly incorrect indentation)
 0
 }}}

-- 
Ticket URL: <http://ghc.haskell.org/trac/ghc/ticket/7962#comment:4>
GHC <http://www.haskell.org/ghc/>
The Glasgow Haskell Compiler




More information about the ghc-tickets mailing list