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.
- csr of
-
JDK-8179856 jshell tool: not suitable for pipeline use
-
- Resolved
-
- relates to
-
JDK-8189593 jshell tool doc: not suitable for pipeline use
-
- Resolved
-