lineedit: don't fall back to simple line input if tty is in raw mode
authorDenys Vlasenko <vda.linux@googlemail.com>
Wed, 10 Dec 2014 16:22:13 +0000 (17:22 +0100)
committerDenys Vlasenko <vda.linux@googlemail.com>
Wed, 10 Dec 2014 16:22:13 +0000 (17:22 +0100)
Testcase: shell command input after python ^Z should still work

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
libbb/lineedit.c

index 85643079b3316c4ca5f75ebbaf0971c51ee08a07..3961b1de3d4b94deca71fb4a65d7ad129bffd07f 100644 (file)
@@ -2256,9 +2256,13 @@ int FAST_FUNC read_line_input(line_input_t *st, const char *prompt, char *comman
        INIT_S();
 
        if (tcgetattr(STDIN_FILENO, &initial_settings) < 0
-        || !(initial_settings.c_lflag & ECHO)
+        || (initial_settings.c_lflag & (ECHO|ICANON)) == ICANON
        ) {
-               /* Happens when e.g. stty -echo was run before */
+               /* Happens when e.g. stty -echo was run before.
+                * But if ICANON is not set, we don't come here.
+                * (example: interactive python ^Z-backgrounded,
+                * tty is still in "raw mode").
+                */
                parse_and_put_prompt(prompt);
                /* fflush_all(); - done by parse_and_put_prompt */
                if (fgets(command, maxsize, stdin) == NULL)