From 47f1ec914b29e04f45d776ada60c3a50a4fbac02 Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 31 Oct 2023 15:10:47 +0100 Subject: [PATCH] Restore partial failure handling with stty, fixes #889 --- .../java/org/jline/terminal/impl/exec/ExecPty.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/terminal/src/main/java/org/jline/terminal/impl/exec/ExecPty.java b/terminal/src/main/java/org/jline/terminal/impl/exec/ExecPty.java index eb5c1b486..7428f93ec 100644 --- a/terminal/src/main/java/org/jline/terminal/impl/exec/ExecPty.java +++ b/terminal/src/main/java/org/jline/terminal/impl/exec/ExecPty.java @@ -101,7 +101,19 @@ protected void doSetAttr(Attributes attr) throws IOException { commands.add(1, OSUtils.STTY_F_OPTION); commands.add(2, getName()); } - exec(systemStream != null, commands.toArray(new String[0])); + try { + exec(systemStream != null, commands.toArray(new String[0])); + } catch (IOException e) { + // Handle partial failures with GNU stty, see #97 + if (e.toString().contains("unable to perform all requested operations")) { + commands = getFlagsToSet(attr, getAttr()); + if (!commands.isEmpty()) { + throw new IOException("Could not set the following flags: " + String.join(", ", commands), e); + } + } else { + throw e; + } + } } }