Skip to content

Commit

Permalink
Issue #519: Use /usr/bin/env stty instead of /bin/stty
Browse files Browse the repository at this point in the history
Hopefully this is more portable across linux distributions
  • Loading branch information
mabe02 committed Oct 11, 2020
1 parent ff52fed commit 217bcd2
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ protected void keyStrokeSignalsEnabled(boolean enabled) throws IOException {
}

protected String runSTTYCommand(String... parameters) throws IOException {
List<String> commandLine = new ArrayList<>(Collections.singletonList(
List<String> commandLine = new ArrayList<>(Arrays.asList(
getSTTYCommand()));
commandLine.addAll(Arrays.asList(parameters));
return exec(commandLine.toArray(new String[0]));
Expand Down Expand Up @@ -174,8 +174,18 @@ protected String exec(String... cmd) throws IOException {
return builder.toString();
}

private String getSTTYCommand() {
return System.getProperty("com.googlecode.lanterna.terminal.UnixTerminal.sttyCommand",
"/bin/stty");
private String[] getSTTYCommand() {
String sttyOverride = System.getProperty("com.googlecode.lanterna.terminal.UnixTerminal.sttyCommand");
if (sttyOverride != null) {
return new String[] { sttyOverride };
}
else {
// Issue #519: this will hopefully be more portable across linux distributions
// Previously we hard-coded "/bin/stty" here
return new String[] {
"/usr/bin/env",
"stty"
};
}
}
}

0 comments on commit 217bcd2

Please sign in to comment.