From 4a94af55a106bd84bd72be6700f813411eb7dd48 Mon Sep 17 00:00:00 2001 From: Nguyễn Thái Ngọc Duy Date: Tue, 21 Sep 2010 18:26:46 +1000 Subject: win32: lineedit: fallback to fgets if a tty is not found --- libbb/lineedit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libbb/lineedit.c b/libbb/lineedit.c index 3af9f4e64..1b88a7141 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c @@ -1914,10 +1914,13 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li INIT_S(); -#if !ENABLE_PLATFORM_MINGW32 +#if ENABLE_PLATFORM_MINGW32 + if (!isatty(0) || !isatty(1)) { +#else if (tcgetattr(STDIN_FILENO, &initial_settings) < 0 || !(initial_settings.c_lflag & ECHO) ) { +#endif /* Happens when e.g. stty -echo was run before */ parse_and_put_prompt(prompt); /* fflush_all(); - done by parse_and_put_prompt */ @@ -1928,7 +1931,6 @@ int FAST_FUNC read_line_input(const char *prompt, char *command, int maxsize, li DEINIT_S(); return len; } -#endif init_unicode(); -- cgit v1.2.3-55-g6feb