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 6275ad3fde GROOVY-11742: posix commands should support variable assignment 6275ad3fde is described below commit 6275ad3fdea3896ff43b973e059533c75d5f98f3 Author: Paul King <pa...@asert.com.au> AuthorDate: Sun Aug 24 13:41:43 2025 +1000 GROOVY-11742: posix commands should support variable assignment --- .../main/groovy/org/apache/groovy/groovysh/Main.groovy | 17 ++++++++++++----- .../groovy/groovysh/jline/GroovyPosixCommands.java | 1 + 2 files changed, 13 insertions(+), 5 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 ffaa9a217c..236e44cd5b 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 @@ -165,7 +165,7 @@ 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 -> + PosixCommands.cd(context(input), ['/cd', *input.args()] as String[], { Path newPath -> posix.context.currentDir = newPath scriptEngine.put('PWD', newPath) }) @@ -176,7 +176,7 @@ class Main { private void ls(CommandInput input) { try { - GroovyPosixCommands.ls(posix.context, ['/ls', *input.args()] as String[]) + GroovyPosixCommands.ls(context(input), ['/ls', *input.args()] as String[]) } catch (Exception e) { saveException(e) } @@ -184,15 +184,21 @@ class Main { private void grepcmd(CommandInput input) { try { - GroovyPosixCommands.grep(posix.context, ['/grep', *input.args()] as String[]) + GroovyPosixCommands.grep(context(input), ['/grep', *input.args()] as String[]) } catch (Exception e) { saveException(e) } } + private GroovyPosixContext context(CommandInput input) { + GroovyPosixContext ctx = new GroovyPosixContext(input.in(), input.out(), input.err(), + posix.context.currentDir(), input.terminal(), scriptEngine::get) + ctx + } + private void cat(CommandInput input) { try { - GroovyPosixCommands.cat(posix.context, ['/cat', *input.args()] as String[]) + GroovyPosixCommands.cat(context(input), ['/cat', *input.args()] as String[]) } catch (Exception e) { saveException(e) } @@ -209,7 +215,8 @@ class Main { private void posix(String[] usage, CommandInput input) { try { parseOptions(usage, input.args()) - posix.execute(input.command(), [input.command(), *input.args()] as String[]) + PosixCommands."${input.command()[1..-1]}"(context(input), [input.command(), *input.args()] as String[]) +// posix.execute(input.command(), [input.command(), *input.args()] as String[]) } catch (Exception e) { saveException(e) } diff --git a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java index 4019daabd5..0bbf4c2370 100644 --- a/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java +++ b/subprojects/groovy-groovysh/src/main/groovy/org/apache/groovy/groovysh/jline/GroovyPosixCommands.java @@ -753,6 +753,7 @@ public class GroovyPosixCommands extends PosixCommands { } match |= nb > 0; } + context.out().flush(); } } }