Skip to content

New check for System.console tty on JDK 22+#8947

Merged
headius merged 2 commits intojruby:masterfrom
headius:jdk22_console_check
Aug 12, 2025
Merged

New check for System.console tty on JDK 22+#8947
headius merged 2 commits intojruby:masterfrom
headius:jdk22_console_check

Conversation

@headius
Copy link
Member

@headius headius commented Aug 7, 2025

This uses the new isTerminal method when running on JDK 22+ due to that version now always returning a non-null Console from System.console().

I may modify the handling of these color-configuring properties such that "true" means "use color if we are outputting to a terminal", defaulting to true.

Fixes #8934.

@headius headius added this to the JRuby 10.0.3.0 milestone Aug 7, 2025
@headius
Copy link
Member Author

headius commented Aug 12, 2025

I added a very basic test that confirms a backtick subprocess does not default to using color. I'm not sure how to guarantee a test for a real TTY will trigger color... probably needs some pty magic I don't know.

We'll go with the simple negative test for now.

@headius headius merged commit 7fbad38 into jruby:master Aug 12, 2025
72 checks passed
@headius headius deleted the jdk22_console_check branch August 12, 2025 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

JRuby under Java 22+ always thinks it's running under a TTY

1 participant