This is an automated email from the ASF dual-hosted git repository.
paulk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/groovy.git
The following commit(s) were added to refs/heads/master by this push:
new 5bd58c01c2 GROOVY-8162: Update Groovysh to JLine3 (workaround for
jline hanging)
5bd58c01c2 is described below
commit 5bd58c01c2da1e6463bed849963bb3f6abb713d6
Author: Paul King <[email protected]>
AuthorDate: Thu Jul 24 14:41:27 2025 +1000
GROOVY-8162: Update Groovysh to JLine3 (workaround for jline hanging)
---
.../main/groovy/org/apache/groovy/groovysh/Main.groovy | 2 +-
.../groovy/groovysh/jline/GroovySystemRegistry.groovy | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
index 83e81a464b..e4e530f0a9 100644
---
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
+++
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/Main.groovy
@@ -305,7 +305,7 @@ class Main {
// remove Groovy continuation character for repl not
Groovy's sake
s.endsWith(' \\') ? s[0..-3] : s
}.collect {s ->
- // repl command parsing assumes whitespace around '='
+ // repl command parsing assumes no whitespace around
'='
s.matches(/[a-zA-Z][a-zA-Z0-9_]* = \S.*/) ?
s.replaceFirst(' = ', '=') : s
}.join('\n')
line = parser.getCommand(line).startsWith("/!") ?
line.replaceFirst("/!", "/! ") : line
diff --git
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovySystemRegistry.groovy
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovySystemRegistry.groovy
index 10e429f270..e9ae808633 100644
---
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovySystemRegistry.groovy
+++
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovySystemRegistry.groovy
@@ -33,6 +33,22 @@ class GroovySystemRegistry extends SystemRegistryImpl {
rename(Pipe.OR, '/||')
}
+ // workaround for: https://github.com/jline/jline3/issues/1361
+ @Override
+ Object execute(String line) throws Exception {
+ def m = line =~ /([a-zA-Z][a-zA-Z0-9_]*)=(\/\S.*)/
+ def target = null
+ if (m.matches()) {
+ (target, line) = m[0][1,2]
+ }
+ super.execute(line)
+ if (target) {
+ consoleEngine().with {
+ putVariable(target, getVariable('_'))
+ }
+ }
+ }
+
@Override
boolean isCommandOrScript(String command) {
return command.startsWith("/!") || super.isCommandOrScript(command)