aboutsummaryrefslogtreecommitdiff
path: root/libbb
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2023-03-06 12:25:39 +0000
committerRon Yorston <rmy@pobox.com>2023-03-06 12:25:39 +0000
commitb50470de96320425adbed82129bdb7f7f5263ddb (patch)
tree129ee385d0d9c658eb7f71717372ea496dd604e1 /libbb
parent8ade494aebe60ea14026d48025a462e6d0b58a7f (diff)
downloadbusybox-w32-b50470de96320425adbed82129bdb7f7f5263ddb.tar.gz
busybox-w32-b50470de96320425adbed82129bdb7f7f5263ddb.tar.bz2
busybox-w32-b50470de96320425adbed82129bdb7f7f5263ddb.zip
win32: virtual terminal input fixes
- Disable ENABLE_PROCESSED_INPUT in raw mode. Otherwise ^C isn't immediately detected during shell command line editing with virtual terminal input enabled. - Switch read_key()/unix_readkey() to windows_read_key()/read_key(). This allows the shell `read` builtin to use windows_read_key(). Without this change `read` fails when virtual terminal input is enabled.
Diffstat (limited to 'libbb')
-rw-r--r--libbb/read_key.c9
-rw-r--r--libbb/xfuncs.c3
2 files changed, 7 insertions, 5 deletions
diff --git a/libbb/read_key.c b/libbb/read_key.c
index c34770028..54886cc9c 100644
--- a/libbb/read_key.c
+++ b/libbb/read_key.c
@@ -9,11 +9,7 @@
9 */ 9 */
10#include "libbb.h" 10#include "libbb.h"
11 11
12#if ENABLE_PLATFORM_MINGW32
13int64_t FAST_FUNC unix_read_key(int fd, char *buffer, int timeout)
14#else
15int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout) 12int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
16#endif
17{ 13{
18 struct pollfd pfd; 14 struct pollfd pfd;
19 const char *seq; 15 const char *seq;
@@ -116,6 +112,11 @@ int64_t FAST_FUNC read_key(int fd, char *buffer, int timeout)
116 0 112 0
117 }; 113 };
118 114
115#if ENABLE_PLATFORM_MINGW32
116 if (!(terminal_mode(FALSE) & VT_INPUT))
117 return windows_read_key(fd, buffer, timeout);
118#endif
119
119 pfd.fd = fd; 120 pfd.fd = fd;
120 pfd.events = POLLIN; 121 pfd.events = POLLIN;
121 122
diff --git a/libbb/xfuncs.c b/libbb/xfuncs.c
index bf15f4c75..cbeb24701 100644
--- a/libbb/xfuncs.c
+++ b/libbb/xfuncs.c
@@ -326,7 +326,8 @@ int FAST_FUNC get_termios_and_make_raw(int fd, struct termios *newterm, struct t
326 *newterm = *oldterm; 326 *newterm = *oldterm;
327 327
328#if ENABLE_PLATFORM_MINGW32 328#if ENABLE_PLATFORM_MINGW32
329 newterm->imode &= ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT); 329 newterm->imode &=
330 ~(ENABLE_ECHO_INPUT | ENABLE_LINE_INPUT | ENABLE_PROCESSED_INPUT);
330#else 331#else
331 /* Turn off buffered input (ICANON) 332 /* Turn off buffered input (ICANON)
332 * Turn off echoing (ECHO) 333 * Turn off echoing (ECHO)