From a21a6a9ab0bfdbb0ea76a7c7d9a21d0f8ec70fa1 Mon Sep 17 00:00:00 2001 From: jacob Date: Fri, 19 Nov 2004 21:05:31 +0000 Subject: [PATCH] console_get_line() returns failure iff console_batch_mode is set, whereas before is would return success and the empty string. IMO this makes `-batch' much more useful; before, utilities such as Plink in `-batch' mode would attempt to plough on using empty strings for usernames, passwords, and so on. git-svn-id: svn://svn.tartarus.org/sgt/putty@4832 cda61777-01e9-0310-a592-d414129be87e --- unix/uxcons.c | 4 +++- windows/wincons.c | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/unix/uxcons.c b/unix/uxcons.c index 3ed7ebf7..00a6835f 100644 --- a/unix/uxcons.c +++ b/unix/uxcons.c @@ -280,6 +280,7 @@ int console_get_line(const char *prompt, char *str, if (console_batch_mode) { if (maxlen > 0) str[0] = '\0'; + return 0; } else { tcgetattr(0, &oldmode); newmode = oldmode; @@ -302,8 +303,9 @@ int console_get_line(const char *prompt, char *str, if (is_pw) fputs("\n", stdout); + + return 1; } - return 1; } void frontend_keypress(void *handle) diff --git a/windows/wincons.c b/windows/wincons.c index 03bb4726..757f753b 100644 --- a/windows/wincons.c +++ b/windows/wincons.c @@ -282,6 +282,7 @@ int console_get_line(const char *prompt, char *str, if (console_batch_mode) { if (maxlen > 0) str[0] = '\0'; + return 0; } else { hin = GetStdHandle(STD_INPUT_HANDLE); hout = GetStdHandle(STD_OUTPUT_HANDLE); @@ -312,8 +313,8 @@ int console_get_line(const char *prompt, char *str, if (is_pw) WriteFile(hout, "\r\n", 2, &i, NULL); + return 1; } - return 1; } void frontend_keypress(void *handle) -- 2.11.0