aboutsummaryrefslogtreecommitdiff
path: root/libbb/lineedit.c
diff options
context:
space:
mode:
authorRon Yorston <rmy@pobox.com>2017-09-27 10:08:12 +0100
committerRon Yorston <rmy@pobox.com>2017-09-27 10:11:19 +0100
commitd9383e984da8de72e61e5094a3cf6404c5707ddc (patch)
treedd42825854fc42aea40d4f7a95548d53721d1733 /libbb/lineedit.c
parent166b3e4e82799f87d3b002c7177891111eff079e (diff)
parent0c4dbd481aedb5d22c1048e7f7eb547a3b5e50a5 (diff)
downloadbusybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.gz
busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.tar.bz2
busybox-w32-d9383e984da8de72e61e5094a3cf6404c5707ddc.zip
Merge branch 'busybox' into merge
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r--libbb/lineedit.c26
1 files changed, 7 insertions, 19 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c
index c2b0a3842..d85057e72 100644
--- a/libbb/lineedit.c
+++ b/libbb/lineedit.c
@@ -2321,7 +2321,7 @@ static int32_t reverse_i_search(int timeout)
2321 */ 2321 */
2322int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize) 2322int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *command, int maxsize)
2323{ 2323{
2324 int len; 2324 int len, n;
2325 int timeout; 2325 int timeout;
2326#if ENABLE_FEATURE_TAB_COMPLETION 2326#if ENABLE_FEATURE_TAB_COMPLETION
2327 smallint lastWasTab = 0; 2327 smallint lastWasTab = 0;
@@ -2336,15 +2336,15 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2336 2336
2337 INIT_S(); 2337 INIT_S();
2338 2338
2339 n = get_termios_and_make_raw(STDIN_FILENO, &new_settings, &initial_settings, 0
2340 | TERMIOS_CLEAR_ISIG /* turn off INTR (ctrl-C), QUIT, SUSP */
2341 );
2339#if ENABLE_PLATFORM_MINGW32 2342#if ENABLE_PLATFORM_MINGW32
2340 memset(initial_settings.c_cc, 0, sizeof(initial_settings.c_cc));
2341 initial_settings.c_cc[VINTR] = CTRL('C'); 2343 initial_settings.c_cc[VINTR] = CTRL('C');
2342 initial_settings.c_cc[VEOF] = CTRL('D'); 2344 initial_settings.c_cc[VEOF] = CTRL('D');
2343 if (!isatty(0) || !isatty(1)) { 2345 if (n > 0 || !isatty(0) || !isatty(1)) {
2344#else 2346#else
2345 if (tcgetattr(STDIN_FILENO, &initial_settings) < 0 2347 if (n != 0 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON) {
2346 || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON
2347 ) {
2348#endif 2348#endif
2349 /* Happens when e.g. stty -echo was run before. 2349 /* Happens when e.g. stty -echo was run before.
2350 * But if ICANON is not set, we don't come here. 2350 * But if ICANON is not set, we don't come here.
@@ -2398,18 +2398,6 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
2398#endif 2398#endif
2399#define command command_must_not_be_used 2399#define command command_must_not_be_used
2400 2400
2401 new_settings = initial_settings;
2402 /* ~ICANON: unbuffered input (most c_cc[] are disabled, VMIN/VTIME are enabled) */
2403 /* ~ECHO, ~ECHONL: turn off echoing, including newline echoing */
2404 /* ~ISIG: turn off INTR (ctrl-C), QUIT, SUSP */
2405 new_settings.c_lflag &= ~(ICANON | ECHO | ECHONL | ISIG);
2406 /* reads will block only if < 1 char is available */
2407 new_settings.c_cc[VMIN] = 1;
2408 /* no timeout (reads block forever) */
2409 new_settings.c_cc[VTIME] = 0;
2410 /* Should be not needed if ISIG is off: */
2411 /* Turn off CTRL-C */
2412 /* new_settings.c_cc[VINTR] = _POSIX_VDISABLE; */
2413 tcsetattr_stdin_TCSANOW(&new_settings); 2401 tcsetattr_stdin_TCSANOW(&new_settings);
2414 2402
2415#if ENABLE_USERNAME_OR_HOMEDIR 2403#if ENABLE_USERNAME_OR_HOMEDIR
@@ -2942,7 +2930,7 @@ int main(int argc, char **argv)
2942#if ENABLE_FEATURE_EDITING_FANCY_PROMPT 2930#if ENABLE_FEATURE_EDITING_FANCY_PROMPT
2943 "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:" 2931 "\\[\\033[32;1m\\]\\u@\\[\\x1b[33;1m\\]\\h:"
2944 "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] " 2932 "\\[\\033[34;1m\\]\\w\\[\\033[35;1m\\] "
2945 "\\!\\[\\e[36;1m\\]\\$ \\[\\E[0m\\]"; 2933 "\\!\\[\\e[36;1m\\]\\$ \\[\\E[m\\]";
2946#else 2934#else
2947 "% "; 2935 "% ";
2948#endif 2936#endif