Skip to content

Commit 47f1ec9

Browse files
committedOct 31, 2023
Restore partial failure handling with stty, fixes #889
1 parent ecbc73a commit 47f1ec9

File tree

1 file changed

+13
-1
lines changed
  • terminal/src/main/java/org/jline/terminal/impl/exec

1 file changed

+13
-1
lines changed
 

‎terminal/src/main/java/org/jline/terminal/impl/exec/ExecPty.java

+13-1
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,19 @@ protected void doSetAttr(Attributes attr) throws IOException {
101101
commands.add(1, OSUtils.STTY_F_OPTION);
102102
commands.add(2, getName());
103103
}
104-
exec(systemStream != null, commands.toArray(new String[0]));
104+
try {
105+
exec(systemStream != null, commands.toArray(new String[0]));
106+
} catch (IOException e) {
107+
// Handle partial failures with GNU stty, see #97
108+
if (e.toString().contains("unable to perform all requested operations")) {
109+
commands = getFlagsToSet(attr, getAttr());
110+
if (!commands.isEmpty()) {
111+
throw new IOException("Could not set the following flags: " + String.join(", ", commands), e);
112+
}
113+
} else {
114+
throw e;
115+
}
116+
}
105117
}
106118
}
107119

0 commit comments

Comments
 (0)
Please sign in to comment.