From 397b2ce82787e946ca926df21dfa8c9857605c25 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 | 2 +- .../org/jline/terminal/impl/exec/ExecPtyTest.java | 12 ++++++++++++ 2 files 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 51eed3481..2e9e5ce26 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 @@ -278,7 +278,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..ef006678f 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,17 @@ 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 +132,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