On Fri, 3 May 2024 10:11:02 GMT, Jan Lahoda <jlah...@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. src/jdk.internal.le/share/classes/jdk/internal/org/jline/JdkConsoleProviderImpl.java line 101: > 99: try { > 100: initJLineIfNeeded(); > 101: return jline.readLine(fmt.formatted(args).replace("%", > "%%")); I understand that [JLine interprets `%` in a prompt](https://github.com/openjdk/jdk/blob/4ed38f5ad5f822ab948257ed39717ea919fd32ed/src/jdk.internal.le/share/classes/jdk/internal/org/jline/reader/impl/LineReaderImpl.java#L4050), but are the interpretation rules documented on JLine GitHub page or elsewhere? src/jdk.internal.le/share/classes/jdk/internal/org/jline/JdkConsoleProviderImpl.java line 116: > 114: try { > 115: initJLineIfNeeded(); > 116: return jline.readLine(fmt.formatted(args).replace("%", > "%%"), '\0') I find `'\0'` more cryptic and confusing than `(char) 0`, but okay. (Had to re-read https://docs.oracle.com/javase/specs/jls/se22/html/jls-3.html#jls-EscapeSequence) test/jdk/jdk/internal/jline/JLineConsoleProviderTest.java line 27: > 25: * @test > 26: * @bug 8331535 > 27: * @summary Verify the jdk.internal.le's console provider works properly. There's a hidden assumption in this test below that the _default_ console is `jdk.internal.le`. Is there any way to assert that? ------------- PR Review Comment: https://git.openjdk.org/jdk/pull/19081#discussion_r1589074603 PR Review Comment: https://git.openjdk.org/jdk/pull/19081#discussion_r1589065719 PR Review Comment: https://git.openjdk.org/jdk/pull/19081#discussion_r1589067927