Current code requires entering a newline character in order to continue past DIR /P prompts. This change allows any key to be pressed instead.
Code to handle this was similar to existing WCMD_pause() so we leveraged that code for this purpose as well. Key to the fix was the removal of ENABLE_LINE_INPUT from the console flags, and ENABLE_PROCESSED_INPUT was added in order to preserve the ability to abort the operation via Ctrl-C.
From: Joe Souza jsouza@yahoo.com
--- programs/cmd/builtins.c | 22 +++++++++++++++++----- programs/cmd/wcmd.h | 1 + programs/cmd/wcmdmain.c | 6 ++---- 3 files changed, 20 insertions(+), 9 deletions(-)
diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index d7c5090d17f..2dea4706c9f 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -1946,12 +1946,13 @@ RETURN_CODE WCMD_move(void) }
/**************************************************************************** - * WCMD_pause + * WCMD_pause_with_message * - * Suspend execution of a batch script until a key is typed + * Suspend execution of a batch script until a key is typed, taking + * the specified message for display. */
-RETURN_CODE WCMD_pause(void) +RETURN_CODE WCMD_pause_with_message(const WCHAR *message) { RETURN_CODE return_code = NO_ERROR; DWORD oldmode; @@ -1962,9 +1963,9 @@ RETURN_CODE WCMD_pause(void)
have_console = GetConsoleMode(hIn, &oldmode); if (have_console) - SetConsoleMode(hIn, 0); + SetConsoleMode(hIn, ENABLE_PROCESSED_INPUT);
- WCMD_output_asis(anykey); + WCMD_output_asis(message); if (!WCMD_ReadFile(hIn, &key, 1, &count) || !count) return_code = ERROR_INVALID_FUNCTION; if (have_console) @@ -1972,6 +1973,17 @@ RETURN_CODE WCMD_pause(void) return return_code; }
+/**************************************************************************** + * WCMD_pause + * + * Suspend execution of a batch script until a key is typed. + */ + +RETURN_CODE WCMD_pause(void) +{ + return WCMD_pause_with_message(anykey); +} + /**************************************************************************** * WCMD_remove_dir * diff --git a/programs/cmd/wcmd.h b/programs/cmd/wcmd.h index 225ebd44310..baabefaad8e 100644 --- a/programs/cmd/wcmd.h +++ b/programs/cmd/wcmd.h @@ -177,6 +177,7 @@ void WINAPIV WCMD_output_stderr (const WCHAR *format, ...); void WCMD_output_asis (const WCHAR *message); void WCMD_output_asis_stderr (const WCHAR *message); RETURN_CODE WCMD_pause(void); +RETURN_CODE WCMD_pause_with_message(const WCHAR *message); RETURN_CODE WCMD_popd(void); void WCMD_print_error (void); RETURN_CODE WCMD_pushd(const WCHAR *args); diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c index 77f1112be23..a5ddd001671 100644 --- a/programs/cmd/wcmdmain.c +++ b/programs/cmd/wcmdmain.c @@ -244,9 +244,7 @@ BOOL WCMD_ReadFile(const HANDLE hIn, WCHAR *intoBuf, const DWORD maxChars, LPDWO * Send output to specified handle without formatting e.g. when message contains '%' */ static void WCMD_output_asis_handle (DWORD std_handle, const WCHAR *message) { - DWORD count; const WCHAR* ptr; - WCHAR string[1024]; HANDLE handle = GetStdHandle(std_handle);
if (paged_mode) { @@ -261,8 +259,8 @@ static void WCMD_output_asis_handle (DWORD std_handle, const WCHAR *message) { numChars = 0; if (++line_count >= max_height - 1) { line_count = 0; - WCMD_output_asis_len(pagedMessage, lstrlenW(pagedMessage), handle); - WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), string, ARRAY_SIZE(string), &count); + WCMD_pause_with_message(pagedMessage); + WCMD_output_asis(L"\r\n"); } } while (((message = ptr) != NULL) && (*ptr)); } else {