Skip to content

Commit

Permalink
Try to fix cygwin / git-win support
Browse files Browse the repository at this point in the history
  • Loading branch information
gnodet committed Jan 8, 2018
1 parent 2e31b52 commit d8a810d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 11 deletions.
12 changes: 5 additions & 7 deletions terminal/src/main/java/org/jline/terminal/TerminalBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -271,11 +271,11 @@ private Terminal doBuild() throws IOException {
Log.warn("Attributes and size fields are ignored when creating a system terminal");
}
IllegalStateException exception = new IllegalStateException("Unable to create a system terminal");
//
// Cygwin support
//
if (OSUtils.IS_CYGWIN || OSUtils.IS_MINGW) {
if (exec) {
if (OSUtils.IS_WINDOWS) {
//
// Cygwin support
//
if ((OSUtils.IS_CYGWIN || OSUtils.IS_MINGW) && exec) {
try {
Pty pty = ExecPty.current();
// Cygwin defaults to XTERM, but actually supports 256 colors,
Expand All @@ -290,8 +290,6 @@ private Terminal doBuild() throws IOException {
exception.addSuppressed(e);
}
}
}
else if (OSUtils.IS_WINDOWS) {
if (jna) {
try {
return load(JnaSupport.class).winSysTerminal(name, encoding, codepage, nativeSignals, signalHandler);
Expand Down
9 changes: 5 additions & 4 deletions terminal/src/main/java/org/jline/utils/OSUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@ public class OSUtils {

public static final boolean IS_MINGW = IS_WINDOWS
&& System.getenv("MSYSTEM") != null
&& System.getenv("MSYSTEM").startsWith("MINGW");
&& System.getenv("MSYSTEM").startsWith("MINGW")
&& !"cygwin".equals(System.getenv("TERM"));

public static final boolean IS_OSX = System.getProperty("os.name").toLowerCase().contains("mac");

Expand All @@ -44,13 +45,13 @@ public class OSUtils {
if (path != null) {
String[] paths = path.split(";");
for (String p : paths) {
if (new File(p, "tty.exe").exists()) {
if (tty == null && new File(p, "tty.exe").exists()) {
tty = new File(p, "tty.exe").getAbsolutePath();
}
if (new File(p, "stty.exe").exists()) {
if (stty == null && new File(p, "stty.exe").exists()) {
stty = new File(p, "stty.exe").getAbsolutePath();
}
if (new File(p, "infocmp.exe").exists()) {
if (infocmp == null && new File(p, "infocmp.exe").exists()) {
infocmp = new File(p, "infocmp.exe").getAbsolutePath();
}
}
Expand Down

0 comments on commit d8a810d

Please sign in to comment.