diff options
Diffstat (limited to 'libbb/lineedit.c')
-rw-r--r-- | libbb/lineedit.c | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/libbb/lineedit.c b/libbb/lineedit.c index c44a22843..f65e852b1 100644 --- a/libbb/lineedit.c +++ b/libbb/lineedit.c | |||
@@ -1259,7 +1259,7 @@ static void win_changed(int nsig) | |||
1259 | * 0 on ctrl-C, | 1259 | * 0 on ctrl-C, |
1260 | * >0 length of input string, including terminating '\n' | 1260 | * >0 length of input string, including terminating '\n' |
1261 | */ | 1261 | */ |
1262 | int read_line_input(const char* prompt, char* command, int maxsize, line_input_t *st) | 1262 | int read_line_input(const char *prompt, char *command, int maxsize, line_input_t *st) |
1263 | { | 1263 | { |
1264 | int lastWasTab = FALSE; | 1264 | int lastWasTab = FALSE; |
1265 | unsigned int ic; | 1265 | unsigned int ic; |
@@ -1270,6 +1270,15 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t | |||
1270 | smalluint prevc; | 1270 | smalluint prevc; |
1271 | #endif | 1271 | #endif |
1272 | 1272 | ||
1273 | getTermSettings(0, (void *) &initial_settings); | ||
1274 | /* Happens when e.g. stty -echo was run before */ | ||
1275 | if (!(initial_settings.c_lflag & ECHO)) { | ||
1276 | parse_prompt(prompt); | ||
1277 | fflush(stdout); | ||
1278 | fgets(command, maxsize, stdin); | ||
1279 | return strlen(command); | ||
1280 | } | ||
1281 | |||
1273 | // FIXME: audit & improve this | 1282 | // FIXME: audit & improve this |
1274 | if (maxsize > MAX_LINELEN) | 1283 | if (maxsize > MAX_LINELEN) |
1275 | maxsize = MAX_LINELEN; | 1284 | maxsize = MAX_LINELEN; |
@@ -1287,7 +1296,6 @@ int read_line_input(const char* prompt, char* command, int maxsize, line_input_t | |||
1287 | command_ps = command; | 1296 | command_ps = command; |
1288 | command[0] = '\0'; | 1297 | command[0] = '\0'; |
1289 | 1298 | ||
1290 | getTermSettings(0, (void *) &initial_settings); | ||
1291 | memcpy(&new_settings, &initial_settings, sizeof(new_settings)); | 1299 | memcpy(&new_settings, &initial_settings, sizeof(new_settings)); |
1292 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ | 1300 | new_settings.c_lflag &= ~ICANON; /* unbuffered input */ |
1293 | /* Turn off echoing and CTRL-C, so we can trap it */ | 1301 | /* Turn off echoing and CTRL-C, so we can trap it */ |