cmd.exe: Add 2>&1 and 1>&2 support.

This commit is contained in:
Jason Edmeades 2007-03-13 00:10:38 +00:00 committed by Alexandre Julliard
parent 4ef2f8ba1a
commit a801995cdb
1 changed files with 29 additions and 10 deletions

View File

@ -533,8 +533,24 @@ void WCMD_process_command (char *command)
else { else {
creationDisposition = CREATE_ALWAYS; creationDisposition = CREATE_ALWAYS;
} }
/* Add support for 2>&1 */
redir = p; redir = p;
h = CreateFile (WCMD_parameter (p, 0, NULL), GENERIC_WRITE, 0, &sa, creationDisposition, if (*p == '&') {
int idx = *(p+1) - '0';
if (DuplicateHandle(GetCurrentProcess(),
GetStdHandle(idx_stdhandles[idx]),
GetCurrentProcess(),
&h,
0, TRUE, DUPLICATE_SAME_ACCESS) == 0) {
WINE_FIXME("Duplicating handle failed with gle %d\n", GetLastError());
}
WINE_TRACE("Redirect %d (%p) to %d (%p)\n", handle, GetStdHandle(idx_stdhandles[idx]), idx, h);
} else {
char *param = WCMD_parameter (p, 0, NULL);
h = CreateFile (param, GENERIC_WRITE, 0, &sa, creationDisposition,
FILE_ATTRIBUTE_NORMAL, NULL); FILE_ATTRIBUTE_NORMAL, NULL);
if (h == INVALID_HANDLE_VALUE) { if (h == INVALID_HANDLE_VALUE) {
WCMD_print_error (); WCMD_print_error ();
@ -545,6 +561,9 @@ void WCMD_process_command (char *command)
INVALID_SET_FILE_POINTER) { INVALID_SET_FILE_POINTER) {
WCMD_print_error (); WCMD_print_error ();
} }
WINE_TRACE("Redirect %d to '%s' (%p)\n", handle, param, h);
}
old_stdhandles[handle] = GetStdHandle (idx_stdhandles[handle]); old_stdhandles[handle] = GetStdHandle (idx_stdhandles[handle]);
SetStdHandle (idx_stdhandles[handle], h); SetStdHandle (idx_stdhandles[handle], h);
} }