Skip to content

Commit

Permalink
Force creation of a dumb terminal if TERM starts with dumb
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Oct 24, 2023
1 parent 405f8fe commit a20ba4b
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand All @@ -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");
}
Expand Down Expand Up @@ -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));
Expand Down

0 comments on commit a20ba4b

Please sign in to comment.