RFR 8177076: jshell tool: allow non-zero /exit

Robert Field robert.field at oracle.com
Thu Nov 2 18:42:50 UTC 2017


Christian,

I've added "The exit status is zero." to the help --

jshell> /help /exit
|
|  /exit
|
|  Leave the jshell tool.  No work is saved.
|  Save any work before using this command
|
|  /exit
|       Leave the jshell tool.  The exit status is zero.
|
|  /exit <integer-expression-snippet>
|       Evaluate the snippet.  If the snippet fails or is not an integer expression,
|       display the error.  Otherwise leave the jshell tool with the
|       value of the expression as the exit status


Which highlights that the API docs should be explicit too.

There is an internal comment on JShellToolProvider.run --

   65      * @return the exit code with which the tool explictly exited (if any),
   66      * otherwise 0 for success or nonzero for failure

I've changed "exit code" to "exit status" as that is what is used by both the javadoc for System.exit() and in the bash docs.
I've fixed the missing "i" in "explictly".
And, a user exit code is of limited use if it is unknown what the tool will return, so I've changed "nonzero" to "1" (which is what the tool uses).
Yielding --

      * @return the exit status with which the tool explicitly exited (if any),
      * otherwise 0 for success or 1 for failure

I then changed the doc on the public API JavaShellToolBuilder.runWithExitCode() which was the below, to be the above --

       * @return the exit code

Thoughts?


Jan,

This still OK?


Thanks,
Robert

On 11/01/17 10:49, Christian Stein wrote:
> Hi Robert,
>
> I'm looking forward to /exit with some code other than zero.
> Allowing a snippet that evaluates to an integer is more than expected.
> Great!
>
> The initial "snippet-less" /exit always returns zero -- this is not (yet)
> documented in the long help text, as far as I can see.
>
> ! Save any work before using this command\n\! \n\! /exit\n\t\!
> Leave the jshell tool\n\n\
>
> Cheers,
> Christian
>
> On Wed, Nov 1, 2017 at 6:35 PM, Robert Field <robert.field at oracle.com>
> wrote:
>
>> A minor update with improvements I was mulling over while I should have
>> been sleeping:
>>
>>      http://cr.openjdk.java.net/~rfield/8185840v1.webrev/
>>
>> -Robert
>>
>> On 10/31/17 22:26, Robert Field wrote:
>>
>>> The seed of this is the ability to exit the jshell tool with a user
>>> specified exit code.  For example:
>>>
>>>      /exit result > base ? 0 : 7
>>>
>>> However, this requires the tool launching API to support passing on the
>>> exit code.
>>> In turn, this requires the tool to return exit codes, and do so correctly
>>> for tool errors.
>>>
>>> This is the first case of a command taking a snippet as an argument.
>>> Input continuation was tied to snippet input processing.
>>> Input, continuation, command, and snippet processing needed to be
>>> unraveled.
>>>
>>> Diagnostic display, formerly only needed for snippets, needed to be
>>> refactored.
>>>
>>> Tab completion needed to be handled in this new case (note integer
>>> context).
>>>
>>> On testing side, StartOptionTest and its subclass ToolProviderTest were a
>>> teetering pile of spaghetti that were not amenable to
>>> the additional demands of the new needed tests.  They have been revamped.
>>>
>>> Bugs:
>>>
>>>      8177076: jshell tool: allow non-zero /exit
>>>      https://bugs.openjdk.java.net/browse/JDK-8185840
>>>
>>>      8190383: JShell API: no way for the jshell tool to report exit status
>>> to provider
>>>      https://bugs.openjdk.java.net/browse/JDK-8190383
>>>
>>> Webrev:
>>>
>>>      http://cr.openjdk.java.net/~rfield/8185840v0.webrev/
>>>
>>> Thanks,
>>> Robert
>>>
>>>



More information about the kulla-dev mailing list