RFR: 8331535: Incorrect prompt for Console.readLine [v3]
Naoto Sato
naoto at openjdk.org
Mon May 6 17:02:56 UTC 2024
On Mon, 6 May 2024 16:09:19 GMT, Jan Lahoda <jlahoda at openjdk.org> wrote:
>> When JLine reads a line, there may be a prompt provided. However, JLine will not interpret the prompt literally, it will handle `%` specially. As a consequence, doing:
>>
>> System.console().readLine("%%s");
>>
>>
>> will not print `%s`, as first `String.format` is used, which will convert `%%s` to `%s`, and then JLine will interpret the `%`. The proposed solution is to duplicate the `%`, so that JLine will print it.
>
> Jan Lahoda has updated the pull request with a new target base due to a merge or a rebase. The pull request now contains eight commits:
>
> - Adjusting test as suggested.
> - Merge branch 'master' into JDK-8331535
> - 8331535: Incorrect prompt for Console.readLine
> - Fixing test.
> - Attempting to stabilize the test.
> - Improving test to really test the redirect while stdin is connected to a terminal.
> - Fixing typo.
> - 8330998: System.console() writes to stderr when stdout is redirected
Looks good
test/jdk/java/io/Console/ConsolePromptTest.java line 29:
> 27: * @summary Verify the java.base's console provider handles the prompt correctly.
> 28: * @library /test/lib
> 29: * @run main/othervm --limit-modules java.base ConsolePromptTest
It would be helpful if we do another run with `-Djdk.console=java.base` too.
-------------
Marked as reviewed by naoto (Reviewer).
PR Review: https://git.openjdk.org/jdk/pull/19081#pullrequestreview-2041252866
PR Review Comment: https://git.openjdk.org/jdk/pull/19081#discussion_r1591300205
More information about the core-libs-dev
mailing list