Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8187439

jshell tool: not suitable for pipeline use

XMLWordPrintable

    • Icon: CSR CSR
    • Resolution: Approved
    • Icon: P3 P3
    • 10
    • tools
    • None
    • minimal

      Summary

      Support use of the jshell tool in pipe chains. Turn off all interactive functionality: terminal interaction, welcome, prompts, automatic restart, etc.

      Problem

      When using the jshell tool with pipes, the tool generates control sequences for the terminal, prints a welcome message, and prints prompts; All of which interfere with user output.

      Solution

      Add a file designator which indicates standard-input. Use the standard "-"

      Specification

      New designator, documented in "jshell --help" as --

      Usage:   jshell <option>... <load file>...
      where possible options include:
      ...
      where file and load file may be a file name or predefined file (DEFAULT, PRINTING,
      or JAVASE); And where load file may be "-" to indicate standard input (no
      interactive terminal interaction will occur).

      Thus, with the "-" file designator, standard input is treated as a load file. Load file handling means: no informative feedback, no prompt, no welcome message, and no pollution of the history. Because standard input is used up as a load file, no interactive input is solicited (there is no need for /exit). Feedback modes are unaffected.

      The output from load files (including "-") are: explicit user output to System.out and System.err, compilation errors, runtime exceptions, unexpected VM termination, and requested output from commands. Feedback modes do not format these and thus have no effect on load file output.

            rfield Robert Field (Inactive)
            jrose John Rose
            John Rose
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated:
              Resolved: