From ceccebc579cf336162ac9aecb3ed9ff33cf0127f Mon Sep 17 00:00:00 2001 From: Guillaume Nodet Date: Tue, 15 Oct 2024 20:09:44 +0200 Subject: [PATCH] Fix ExecPty parsing on some Alpine linux (fixes #1091) --- .../java/org/jline/terminal/impl/exec/ExecPty.java | 3 ++- .../org/jline/terminal/impl/exec/ExecPtyTest.java | 13 +++++++++++++ 2 files changed, 15 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 51eed3481..ec34e3192 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 @@ -30,6 +30,7 @@ import org.jline.terminal.spi.Pty; import org.jline.terminal.spi.SystemStream; import org.jline.terminal.spi.TerminalProvider; +import org.jline.utils.Log; import org.jline.utils.OSUtils; import static org.jline.utils.ExecHelper.exec; @@ -278,7 +279,7 @@ static int doGetInt(String name, String cfg) throws IOException { return Integer.parseInt(matcher.group(1)); } } - throw new IOException("Unable to parse " + name); + return 0; } @Override diff --git a/terminal/src/test/java/org/jline/terminal/impl/exec/ExecPtyTest.java b/terminal/src/test/java/org/jline/terminal/impl/exec/ExecPtyTest.java index a67165e0b..2e1dd67e3 100644 --- a/terminal/src/test/java/org/jline/terminal/impl/exec/ExecPtyTest.java +++ b/terminal/src/test/java/org/jline/terminal/impl/exec/ExecPtyTest.java @@ -112,6 +112,18 @@ public class ExecPtyTest { + "-echoctl -echoprt -echoke -flusho -pendin\n" + "opost -olcuc onlcr -ocrnl -onocr -onlret -ofill -ofdel -tostop"; + private final String alpineSample = "speed 38400 baud;stty: standard input\n" + + " line = 0;\n" + + "intr = ^C; quit = ^\\; erase = ^?; kill = ^U; eof = ^D; eol = ;\n" + + "eol2 = ; swtch = ; start = ^Q; stop = ^S; susp = ^Z; rprnt = ^R;\n" + + "werase = ^W; lnext = ^V; flush = ^O; min = 1; time = 0;\n" + + "-parenb -parodd -cmspar cs8 -hupcl -cstopb cread -clocal -crtscts\n" + + "-ignbrk -brkint -ignpar -parmrk -inpck -istrip -inlcr -igncr icrnl ixon -ixoff\n" + + "-iuclc -ixany -imaxbel -iutf8\n" + + "opost -olcuc -ocrnl onlcr -onocr -onlret -ofill -ofdel nl0 cr0 tab0 bs0 vt0 ff0\n" + + "isig icanon iexten echo echoe echok -echonl -noflsh -xcase -tostop -echoprt\n" + + "echoctl echoke -flusho -extproc"; + @Test public void testParseSize() throws IOException { assertEquals(new Size(244, 85), ExecPty.doGetSize(linuxSttySample)); @@ -121,6 +133,7 @@ public void testParseSize() throws IOException { assertEquals(new Size(244, 85), ExecPty.doGetSize(netBsdSttySample)); assertEquals(new Size(244, 85), ExecPty.doGetSize(freeBsdSttySample)); assertEquals(new Size(244, 85), ExecPty.doGetSize(hpuxSttySample)); + assertEquals(new Size(0, 0), ExecPty.doGetSize(alpineSample)); } @Test