This seems like a really silly question, but when I use groovysh
, if I have a typo, it seems to kill the entire shell.
For example, if I want to iterate through an array, I can do this arr.each { elt ->
. But if I accidentally type arr.each { elt =>
, then every future line I type results in
groovysh_parse: 2: unexpected token: > @ line 2, column 13.
arr.each { elt =>
^
I can't get back to a working shell without killing the shell and restarting it, which means I lose all the work I've done in the shell.
Is there a way to get out of this?
There are a couple ways to get out of this. One is to clear the entire buffer using :c
. The other is to edit the current buffer and fix your typo using :e
.
In older versions of Groovy, the command prefix was '\' i.e. \c
and \e
.