From a20ba4b5b1326a6a4371f51ed0d4eb618848cb7d Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Mon, 23 Oct 2023 13:31:53 +0200 Subject: [PATCH] Force creation of a dumb terminal if TERM starts with dumb --- .../main/java/org/jline/terminal/TerminalBuilder.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java b/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java index 484809b93..fb1426937 100644 --- a/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java +++ b/terminal/src/main/java/org/jline/terminal/TerminalBuilder.java @@ -29,6 +29,7 @@ import org.jline.terminal.impl.AbstractPosixTerminal; import org.jline.terminal.impl.AbstractTerminal; +import org.jline.terminal.impl.DumbTerminal; import org.jline.terminal.impl.DumbTerminalProvider; import org.jline.terminal.spi.SystemStream; import org.jline.terminal.spi.TerminalProvider; @@ -367,6 +368,8 @@ private Terminal doBuild() throws IOException { Charset encoding = computeEncoding(); String type = computeType(); + boolean forceDumb = + (DumbTerminal.TYPE_DUMB.equals(type) || type != null && type.startsWith(DumbTerminal.TYPE_DUMB_COLOR)); Boolean dumb = this.dumb; if (dumb == null) { dumb = getBoolean(PROP_DUMB, null); @@ -389,7 +392,7 @@ private Terminal doBuild() throws IOException { stream -> stream, stream -> providers.stream().anyMatch(p -> p.isSystemStream(stream)))); SystemStream systemStream = select(system, systemOutput); - if (system.get(SystemStream.Input) && systemStream != null) { + if (!forceDumb && system.get(SystemStream.Input) && systemStream != null) { if (attributes != null || size != null) { Log.warn("Attributes and size fields are ignored when creating a system terminal"); } @@ -437,8 +440,8 @@ private Terminal doBuild() throws IOException { terminal = null; } } - if (terminal == null && (dumb == null || dumb)) { - if (dumb == null) { + if (terminal == null && (forceDumb || dumb == null || dumb)) { + if (!forceDumb && dumb == null) { if (Log.isDebugEnabled()) { Log.warn("input is tty: {}", system.get(SystemStream.Input)); Log.warn("output is tty: {}", system.get(SystemStream.Output));