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 561244e5853b0856f3f9defca303b56baabe95ca Author: Paul King <pa...@asert.com.au> AuthorDate: Mon Aug 25 19:46:50 2025 +1000 merge upstream improvement --- .../apache/groovy/groovysh/jline/GroovyPosixCommands.java | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) 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 445a03f08e..cb7aa2c25c 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 @@ -518,9 +518,7 @@ public class GroovyPosixCommands extends PosixCommands { if (opt.args().isEmpty()) { expanded.add(currentDir); } else { - opt.args().forEach(s -> { - expanded.addAll(maybeExpandGlob(context, s)); - }); + opt.args().stream().flatMap(s -> maybeExpandGlob(context, s)).forEach(expanded::add); } boolean listAll = opt.isSet("a"); Predicate<Path> filter = p -> listAll @@ -901,7 +899,7 @@ public class GroovyPosixCommands extends PosixCommands { } else if (arg.startsWith("[Ljava.lang.String;@")) { sources.add(new NamedInputStream(variableInputStream(argv, arg), arg)); } else { - sources.addAll(maybeExpandGlob(context, arg).stream() + sources.addAll(maybeExpandGlob(context, arg) .map(gp -> new NamedInputStream(newInputStream(gp), gp.toString())) .collect(Collectors.toList())); } @@ -926,7 +924,7 @@ public class GroovyPosixCommands extends PosixCommands { if ("-".equals(arg)) { sources.add(new Source.StdInSource(context.in())); } else { - sources.addAll(maybeExpandGlob(context, arg).stream() + sources.addAll(maybeExpandGlob(context, arg) .map(p -> { try { return new Source.URLSource(p.toUri().toURL(), p.toString()); @@ -1024,11 +1022,11 @@ public class GroovyPosixCommands extends PosixCommands { return perms; } - private static List<Path> maybeExpandGlob(Context context, String s) { + private static Stream<Path> maybeExpandGlob(Context context, String s) { if (s.contains("*") || s.contains("?")) { - return expandGlob(context, s); + return expandGlob(context, s).stream(); } - return Collections.singletonList(context.currentDir().resolve(s)); + return Stream.of(context.currentDir().resolve(s)); } private static List<Path> expandGlob(Context context, String pattern) {