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 54fca04374 GROOVY-8162: Update Groovysh to JLine3 (add PWD variable)
54fca04374 is described below
commit 54fca04374006bc024ef70ab1fede4113564e6c1
Author: Paul King <[email protected]>
AuthorDate: Tue Aug 12 10:37:29 2025 +1000
GROOVY-8162: Update Groovysh to JLine3 (add PWD variable)
---
.../main/groovy/org/apache/groovy/groovysh/Main.groovy | 16 ++++++++++------
1 file changed, 10 insertions(+), 6 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 74c6e0b0c8..25cf7824f0 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
@@ -86,13 +86,13 @@ class Main {
@SuppressWarnings("resource")
protected static class ExtraConsoleCommands extends JlineCommandRegistry
implements CommandRegistry {
private final LineReader reader
- private final Map<String, Object> variables
+ private final GroovyEngine scriptEngine
private PosixCommandsRegistry posix
private final Map<String, String[]> usage = [:]
- ExtraConsoleCommands(Path workDir, Map<String, Object> variables,
LineReader reader) {
+ ExtraConsoleCommands(Path workDir, GroovyEngine scriptEngine,
LineReader reader) {
super()
- this.variables = variables
+ this.scriptEngine = scriptEngine
this.reader = reader
def terminal = reader.terminal
def context = new GroovyPosixContext(
@@ -101,7 +101,7 @@ class Main {
new PrintStream(terminal.output()),
workDir,
terminal,
- variables::get
+ scriptEngine::get
)
posix = new PosixCommandsRegistry(context)
def cmds = [
@@ -161,7 +161,10 @@ class Main {
private void cd(CommandInput input) {
try {
parseOptions(adjustUsage('cd', '/cd'), input.args())
- PosixCommands.cd(posix.context, ['/cd', *input.args()] as
String[], { Path newPath -> posix.context.currentDir = newPath })
+ PosixCommands.cd(posix.context, ['/cd', *input.args()] as
String[], { Path newPath ->
+ posix.context.currentDir = newPath
+ scriptEngine.put('PWD', newPath)
+ })
} catch (Exception e) {
saveException(e)
}
@@ -347,8 +350,9 @@ class Main {
LineReader.BLINK_MATCHING_PAREN, 0) // if enabled cursor
remains in begin parenthesis (gitbash)
}
- def extra = new
ExtraConsoleCommands(Paths.get(System.getProperty('user.dir')),
scriptEngine.variables, reader)
+ def extra = new
ExtraConsoleCommands(Paths.get(System.getProperty('user.dir')), scriptEngine,
reader)
Supplier<Path> workDir = extra::currentDir
+ scriptEngine.put('PWD', workDir.get())
CommandRegistry groovy = new GroovyCommands(scriptEngine, workDir,
printer, groovyHighlighter)