cmd: Fix builtin for with /f parameter

André Hentschel nerv at dawncrow.de
Fri Apr 23 12:30:22 CDT 2010


That's an obvious Problem
---
 programs/cmd/builtins.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/programs/cmd/builtins.c b/programs/cmd/builtins.c
index 8049ed8..adf516c 100644
--- a/programs/cmd/builtins.c
+++ b/programs/cmd/builtins.c
@@ -899,18 +899,19 @@ void WCMD_for (WCHAR *p, CMD_LIST **cmdList) {
           if (*itemStart == '`' || *itemStart == '\'') {
 
               WCHAR temp_path[MAX_PATH], temp_cmd[MAXSTRING];
-              static const WCHAR redirOut[] = {'>','%','s','\0'};
+              static const WCHAR redirOut[] = {'%','s','>','%','s','\0'};
               static const WCHAR cmdW[]     = {'C','M','D','\0'};
 
-              /* Remove trailing character */
+              /* Remove first and trailing character */
               itemStart[strlenW(itemStart)-1] = 0x00;
+              itemStart++;
 
               /* Get temp filename */
               GetTempPathW(sizeof(temp_path)/sizeof(WCHAR), temp_path);
               GetTempFileNameW(temp_path, cmdW, 0, temp_file);
 
               /* Execute program and redirect output */
-              wsprintfW(temp_cmd, redirOut, (itemStart+1), temp_file);
+              wsprintfW(temp_cmd, redirOut, itemStart, temp_file);
               WCMD_execute (itemStart, temp_cmd, NULL, NULL, NULL);
 
               /* Open the file, read line by line and process */
-- 

Best Regards, André Hentschel



More information about the wine-patches mailing list