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 45897f82a9 GROOVY-8162: Update Groovysh to JLine3 (avoid hang for more cases) 45897f82a9 is described below commit 45897f82a9155517d6c7e34997543b4b0a8a458d Author: Paul King <pa...@asert.com.au> AuthorDate: Tue Jul 29 14:04:41 2025 +1000 GROOVY-8162: Update Groovysh to JLine3 (avoid hang for more cases) --- .../groovy/org/apache/groovy/groovysh/Main.groovy | 4 ---- .../groovysh/jline/GroovySystemRegistry.groovy | 21 ++++++++++++++++----- 2 files changed, 16 insertions(+), 9 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 abeaf83ad7..61b6083fd3 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 @@ -304,11 +304,7 @@ class Main { line = line.readLines().collect{ s -> // remove Groovy continuation character for repl not Groovy's sake s.endsWith(' \\') ? s[0..-3] : s - }.collect {s -> - // repl command parsing assumes no whitespace around '=' - s.matches(/[a-zA-Z][a-zA-Z0-9_]*\s*=\s*\/\S.*/) ? s.replaceFirst(/\s*=\s*/, '=') : s }.join('\n') - line = parser.getCommand(line).startsWith("/!") ? line.replaceFirst("/!", "/! ") : line if (line.startsWith(':')) { def maybeCmd = line.split()[0].replaceFirst(':', '/') if (systemRegistry.hasCommand(maybeCmd) || systemRegistry.isCommandAlias(maybeCmd)) { 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 4d37f77d5e..8bfb7277d2 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 @@ -29,22 +29,33 @@ import java.util.function.Supplier class GroovySystemRegistry extends SystemRegistryImpl { GroovySystemRegistry(Parser parser, Terminal terminal, Supplier<Path> workDir, ConfigurationPath configPath) { super(parser, terminal, workDir, configPath) - rename(Pipe.AND, '/&&') - rename(Pipe.OR, '/||') + rename(Pipe.AND, '|&&') + 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 m = line =~ /([a-zA-Z][a-zA-Z0-9_]*)(\s*)=(\s*)(\/?)(\S.*)/ def target = null if (m.matches()) { - (target, line) = m[0][1,2] + def (_, variable, space1, space2, slash, rhs) = m[0] + if (slash) { + target = variable + line = slash + rhs + line = line.startsWith("/!") ? line.replaceFirst("/!", "/! ") : line + } else { + space1 = space1.size() == 0 ? ' ' : space1 + space2 = space2.size() == 0 ? ' ' : space2 + line = "$variable$space1=$space2$rhs" + } } def result = super.execute(line) if (target) { consoleEngine().with { - putVariable(target, getVariable('_')) + if (hasVariable('_')) { + putVariable(target, getVariable('_')) + } } } result