You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@groovy.apache.org by pa...@apache.org on 2025/07/19 05:13:29 UTC
(groovy) 02/02: tweak regex
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
commit 7d757d79a4fa97069bfd849297718076c088a963
Author: Paul King <pa...@asert.com.au>
AuthorDate: Sat Jul 19 15:13:17 2025 +1000
tweak regex
---
.../main/groovy/org/apache/groovy/groovysh/Main.groovy | 17 ++++++++++-------
1 file changed, 10 insertions(+), 7 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 e6a0630649..3bbb795949 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
@@ -179,7 +179,7 @@ class Main {
try {
Supplier<Path> workDir = () -> Paths.get(System.getProperty('user.dir'))
DefaultParser parser = new DefaultParser(
- regexCommand: /\/?[a-zA-Z!]+\S*/,
+ regexCommand: /\/?[a-zA-Z!]\S*/,
eofOnUnclosedQuote: true,
eofOnEscapedNewLine: true
)
@@ -288,22 +288,25 @@ class Main {
println render(messages['startup_banner.1'])
println '-' * (terminal.width - 1)
// for debugging
-// def index = 0
-// def lines = ['println \\', 'new Date()',
-// '/q']
+ def index = 0
+ def lines = ['/slurp /Users/paulk/Projects/groovy/subprojects/groovy-json/src/test/resources/groovy9802.json',
+ 'println _',
+ 'x = /slurp /Users/paulk/Projects/groovy/subprojects/groovy-json/src/test/resources/groovy9802.json',
+ 'println x',
+ '/q']
// REPL-loop
while (true) {
try {
systemRegistry.cleanUp() // delete temporary variables and reset output streams
// for debugging
-// String line = lines[index++]
- String line = reader.readLine("groovy> ")
+ String line = lines[index++]
+// String line = reader.readLine("groovy> ")
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 whitespace around '='
- s.matches(/[a-zA-Z0-9._]*=\S.*/) ? s.replaceFirst('=', ' = ') : s
+ s.matches(/[a-zA-Z][a-zA-Z0-9_]* = \S.*/) ? s.replaceFirst(' = ', '=') : s
}.join('\n')
line = parser.getCommand(line).startsWith("/!") ? line.replaceFirst("/!", "/! ") : line
if (line.startsWith(':')) {