From bc176ecb8140f319355874790ea307e9156ab8df Mon Sep 17 00:00:00 2001 From: Francois Gouget Date: Fri, 2 Dec 2011 10:07:27 +0100 Subject: [PATCH] cmd: Print error messages on stderr, not on stdout. --- programs/cmd/builtins.c | 20 ++++++++++---------- programs/cmd/tests/test_builtins.cmd | 1 - programs/cmd/tests/test_builtins.cmd.exp | 7 +++---- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c index 60f9f992356..216a28ba5c6 100644 --- a/programs/cmd/builtins.c +++ b/programs/cmd/builtins.c @@ -194,7 +194,7 @@ void WCMD_clear_screen (void) { void WCMD_change_tty (void) { - WCMD_output (WCMD_LoadMessage(WCMD_NYI)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI)); } @@ -390,7 +390,7 @@ void WCMD_copy (void) { WCHAR ext[MAX_PATH]; if (param1[0] == 0x00) { - WCMD_output (WCMD_LoadMessage(WCMD_NOARG)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_NOARG)); return; } @@ -1135,7 +1135,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { /* Ensure line continues with variable */ if (!*curPos || *curPos != '%') { - WCMD_output (WCMD_LoadMessage(WCMD_SYNTAXERR)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_SYNTAXERR)); return; } @@ -1154,7 +1154,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { if (!*curPos || !WCMD_keyword_ws_found(inW, sizeof(inW)/sizeof(inW[0]), curPos)) { - WCMD_output (WCMD_LoadMessage(WCMD_SYNTAXERR)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_SYNTAXERR)); return; } @@ -1181,7 +1181,7 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) { if ((*cmdList == NULL) || !WCMD_keyword_ws_found(doW, sizeof(doW)/sizeof(doW[0]), (*cmdList)->command)) { - WCMD_output (WCMD_LoadMessage(WCMD_SYNTAXERR)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_SYNTAXERR)); return; } @@ -2199,14 +2199,14 @@ void WCMD_setshow_date (void) { WCMD_output (WCMD_LoadMessage(WCMD_NEWDATE)); WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, sizeof(buffer)/sizeof(WCHAR), &count); if (count > 2) { - WCMD_output (WCMD_LoadMessage(WCMD_NYI)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI)); } } } else WCMD_print_error (); } else { - WCMD_output (WCMD_LoadMessage(WCMD_NYI)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI)); } } @@ -2427,14 +2427,14 @@ void WCMD_setshow_time (void) { WCMD_output (WCMD_LoadMessage(WCMD_NEWTIME)); WCMD_ReadFile(GetStdHandle(STD_INPUT_HANDLE), buffer, sizeof(buffer)/sizeof(WCHAR), &count); if (count > 2) { - WCMD_output (WCMD_LoadMessage(WCMD_NYI)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI)); } } } else WCMD_print_error (); } else { - WCMD_output (WCMD_LoadMessage(WCMD_NYI)); + WCMD_output_stderr (WCMD_LoadMessage(WCMD_NYI)); } } @@ -2515,7 +2515,7 @@ void WCMD_type (WCHAR *command) { FILE_ATTRIBUTE_NORMAL, NULL); if (h == INVALID_HANDLE_VALUE) { WCMD_print_error (); - WCMD_output(WCMD_LoadMessage(WCMD_READFAIL), thisArg); /* should be _stderr */ + WCMD_output_stderr(WCMD_LoadMessage(WCMD_READFAIL), thisArg); errorlevel = 1; } else { if (writeHeaders) { diff --git a/programs/cmd/tests/test_builtins.cmd b/programs/cmd/tests/test_builtins.cmd index f03a05e4e81..6295f9e311f 100644 --- a/programs/cmd/tests/test_builtins.cmd +++ b/programs/cmd/tests/test_builtins.cmd @@ -141,7 +141,6 @@ if 1==1 (echo foo2>bar) else echo baz2>bar type bar & del bar if 1==1 (echo foo3) else echo baz3>bar type bar || echo file does not exist, ok -echo ----- if 1==1 (echo foo4>bar) else echo baz4>bar type bar & del bar if 1==0 (echo foo5>bar) else echo baz5>bar diff --git a/programs/cmd/tests/test_builtins.cmd.exp b/programs/cmd/tests/test_builtins.cmd.exp index a005fc25061..7537ebc7d2d 100644 --- a/programs/cmd/tests/test_builtins.cmd.exp +++ b/programs/cmd/tests/test_builtins.cmd.exp @@ -166,8 +166,7 @@ food21 ----- foo2 foo3 -@todo_wine@file does not exist, ok -@todo_wine@----- +file does not exist, ok foo4 baz5 baz6@space@ @@ -190,8 +189,8 @@ baz @todo_wine@foo | echo bar @todo_wine@foo & echo bar @todo_wine@bak & -@todo_wine@baz@space@ -@todo_wine@0@or_broken@1 +baz@space@ +0@or_broken@1 @todo_wine@foo > foo @todo_wine@< @todo_wine@ffoof