cmd: Dont assume cmd.exe is the first argument (try 2)

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Wed Mar 19 17:23:49 CDT 2014


Hi,
Correctly skip to the next argument.

Changelog:
       cmd: Dont assume cmd.exe is the first argument


Best Regards
   Alistair Leslie-Hughes
-------------- next part --------------
>From 804d1ef9fc6cc2a302e41dfc3d19acdbef2adb1e Mon Sep 17 00:00:00 2001
From: Alistair Leslie-Hughes <leslie_alistair at hotmail.com>
Date: Sat, 15 Mar 2014 20:00:06 +1100
Subject: [PATCH] Dont assume cmd.exe is the first argument
To: wine-patches <wine-patches at winehq.org>

---
 programs/cmd/wcmdmain.c | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 647f988..0c1afb1 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -2339,6 +2339,7 @@ int wmain (int argc, WCHAR *argvW[])
   static const WCHAR offW[] = {'O','F','F','\0'};
   static const WCHAR promptW[] = {'P','R','O','M','P','T','\0'};
   static const WCHAR defaultpromptW[] = {'$','P','$','G','\0'};
+  static const WCHAR cmdexe[] = {'c','m','d','.','e','x','e','\0'};
   CMD_LIST *toExecute = NULL;         /* Commands left to be executed */
   OSVERSIONINFOW osv;
   char osver[50];
@@ -2363,7 +2364,7 @@ int wmain (int argc, WCHAR *argvW[])
    */
   cmdLine = GetCommandLineW();
   WINE_TRACE("Full commandline '%s'\n", wine_dbgstr_w(cmdLine));
-  args = 1;                /* start at first arg, skipping cmd.exe itself */
+  args = 0;
 
   opt_c = opt_k = opt_q = opt_s = FALSE;
   WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
@@ -2371,6 +2372,14 @@ int wmain (int argc, WCHAR *argvW[])
   {
       WCHAR c;
       WINE_TRACE("Command line parm: '%s'\n", wine_dbgstr_w(argPos));
+
+      /* skip "cmd.exe" if it is the first parameter */
+      if(args == 0 && strstrW(argPos, cmdexe) != NULL) {
+          args++;
+          WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
+          continue;
+      }
+
       if (argPos[0]!='/' || argPos[1]=='\0') {
           args++;
           WCMD_parameter(cmdLine, args, &argPos, TRUE, TRUE);
-- 
1.8.3.2



More information about the wine-patches mailing list