Search code examples
groovygroovyshell

GroovyShell exit multiline


GroovyShell doesn't seem to exit multiline when invalid input is entered. Example:

groovy:000> InvalidClosure {
groovy:001> meaninglessCommands
groovy:002> }
ERROR groovy.lang.MissingMethodException:
No signature of method: groovysh_evaluate.InvalidClosure() is applicable 
for argument types: (groovysh_evaluate$_run_closure1) values: 
[groovysh_evaluate$_run_closure1@5a9f4771]
groovy:002>

I can't get back to groovy:000> no matter what I try, and the REPL keeps interpreting the invalid commands, since it understands I'm still on the same multiline command.

How do I exit from this multiline instance?


Solution

  • Just type :clear.

    groovy:000> ?
    [...]
    Available commands:
      :help      (:h ) Display this help message
      ?          (:? ) Alias to: :help
    [...]
      :display   (:d ) Display the current buffer
      :clear     (:c ) Clear the buffer and reset the prompt counter
    [...]