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 c253e8d00a GROOVY-8162: Update Groovysh to JLine3 (rollback variable
assignment workaround fixed in 3.30.5)
c253e8d00a is described below
commit c253e8d00aae5022231bb41d6ef416213bfa95e0
Author: Paul King <[email protected]>
AuthorDate: Wed Aug 13 13:19:54 2025 +1000
GROOVY-8162: Update Groovysh to JLine3 (rollback variable assignment
workaround fixed in 3.30.5)
---
.../groovy/org/apache/groovy/groovysh/Main.groovy | 4 ++--
.../groovy/groovysh/jline/GroovyCommands.groovy | 3 ++-
.../groovysh/jline/GroovySystemRegistry.groovy | 25 ++++++----------------
3 files changed, 10 insertions(+), 22 deletions(-)
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 6e0e3d4cfb..7e314dd16b 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
@@ -432,12 +432,12 @@ class Main {
try {
systemRegistry.cleanUp() // delete temporary variables and
reset output streams
String line
-// for debugging
-// line = lines[index++]
if (evaluate) {
line = evaluate
evaluate = null
} else {
+ // for debugging
+// line = lines[index++]
line = reader.readLine("groovy> ")
}
line = line.readLines().collect{ s ->
diff --git
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyCommands.groovy
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyCommands.groovy
index ab12f86a5e..a4f23ca4a6 100644
---
a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyCommands.groovy
+++
b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyCommands.groovy
@@ -231,7 +231,7 @@ class GroovyCommands extends JlineCommandRegistry
implements CommandRegistry {
loadFile(engine, workDir.get().resolve(arg).toFile(), merge)
}
- void slurpcmd(CommandInput input) {
+ def slurpcmd(CommandInput input) {
checkArgCount(input, [0, 1, 2, 3, 4])
if (maybePrintHelp(input, '/slurp')) return
Charset encoding = StandardCharsets.UTF_8
@@ -324,6 +324,7 @@ class GroovyCommands extends JlineCommandRegistry
implements CommandRegistry {
throw ignore
}
engine.put("_", out)
+ out
}
Object getParser(String format, String parserName) {
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 e3b0350823..85a0994676 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,32 +33,19 @@ class GroovySystemRegistry extends SystemRegistryImpl {
rename(Pipe.OR, '|||')
}
- // workaround for: https://github.com/jline/jline3/issues/1361
@Override
Object execute(String line) throws Exception {
line = line.startsWith("/!") ? line.replaceFirst("/!", "/! ") : line
- def m = line =~ /([a-zA-Z][a-zA-Z0-9_]*)(\s*)=(\s*)(\/?)(\S.*)/
- def target = null
+ // SystemRegistryImpl assumes we have no spaces around the '=' in
variable assignments
+ // for commands, so we adjust here to support Groovy idiomatic syntax.
+ def m = line =~ /([a-zA-Z][a-zA-Z0-9_]*)\s*=\s*(\/?)(\S.*)/
if (m.matches()) {
- def (_, variable, space1, space2, slash, rhs) = m[0]
+ def (_, variable, slash, rhs) = m[0]
if (slash) {
- target = variable
- line = slash + rhs
- } else {
- space1 = space1.size() == 0 ? ' ' : space1
- space2 = space2.size() == 0 ? ' ' : space2
- line = "$variable$space1=$space2$rhs"
+ line = variable + '=' + slash + rhs
}
}
- def result = super.execute(line)
- if (target) {
- consoleEngine().with {
- if (hasVariable('_')) {
- putVariable(target, getVariable('_'))
- }
- }
- }
- result
+ super.execute(line)
}
@Override