JShell proposal: /exit_if {predicate}

Brian Goetz brian.goetz at oracle.com
Mon May 13 16:08:21 UTC 2019


JShell was designed to be an interactive environment, not a batch runner.  Though I understand why you would want to apply it as such, features like this serve merely to dilute the design center, ultimately at the expense of its core mission.  

There is a story for batch execution: JEP 330 (https://openjdk.java.net/jeps/330 <https://openjdk.java.net/jeps/330>).  


> On May 13, 2019, at 12:03 PM, Christian Stein <sormuras at gmail.com> wrote:
> 
> Hi!
> 
> I often find me writing JShell-based scripts like [1] that chain
> calls to various tools or functions. To achieve a "fail-fast" on
> first error behaviour, I store an "all-is-okay" flag and guard
> each tool call by a checking the flag for a zero, indicating all
> is still okay, proceed with next call.
> 
> It'd be super convenient if there was a JShell command that
> wraps that feature. Something like the following pseudo-code:
> 
> /exit_if 5 - 4 == 2
> /exit_if Files.isSameFile()
> 
> Cheers,
> Christian
> 
> [1] https://github.com/sormuras/make-java/blob/master/build.jsh



More information about the kulla-dev mailing list