Jason Edmeades : cmd: Ensure current directory saved during cmd /c.

Alexandre Julliard julliard at winehq.org
Mon Oct 1 13:35:07 CDT 2012


Module: wine
Branch: master
Commit: 4e10456bf61c444bac39ad278e63aa5a9e9cb399
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4e10456bf61c444bac39ad278e63aa5a9e9cb399

Author: Jason Edmeades <jason at edmeades.me.uk>
Date:   Mon Oct  1 00:12:59 2012 +0100

cmd: Ensure current directory saved during cmd /c.

---

 programs/cmd/wcmdmain.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/programs/cmd/wcmdmain.c b/programs/cmd/wcmdmain.c
index 64dd21d..02babea 100644
--- a/programs/cmd/wcmdmain.c
+++ b/programs/cmd/wcmdmain.c
@@ -2509,6 +2509,15 @@ int wmain (int argc, WCHAR *argvW[])
           WCMD_strip_quotes(cmd);
   }
 
+  /* Save cwd into appropriate env var (Must be before the /c processing */
+  GetCurrentDirectoryW(sizeof(string)/sizeof(WCHAR), string);
+  if (IsCharAlphaW(string[0]) && string[1] == ':') {
+    static const WCHAR fmt[] = {'=','%','c',':','\0'};
+    wsprintfW(envvar, fmt, string[0]);
+    SetEnvironmentVariableW(envvar, string);
+    WINE_TRACE("Set %s to %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(string));
+  }
+
   if (opt_c) {
       /* If we do a "cmd /c command", we don't want to allocate a new
        * console since the command returns immediately. Rather, we use
@@ -2602,15 +2611,6 @@ int wmain (int argc, WCHAR *argvW[])
 
   }
 
-  /* Save cwd into appropriate env var */
-  GetCurrentDirectoryW(1024, string);
-  if (IsCharAlphaW(string[0]) && string[1] == ':') {
-    static const WCHAR fmt[] = {'=','%','c',':','\0'};
-    wsprintfW(envvar, fmt, string[0]);
-    SetEnvironmentVariableW(envvar, string);
-    WINE_TRACE("Set %s to %s\n", wine_dbgstr_w(envvar), wine_dbgstr_w(string));
-  }
-
   if (opt_k) {
       /* Parse the command string, without reading any more input */
       WCMD_ReadAndParseLine(cmd, &toExecute, INVALID_HANDLE_VALUE);




More information about the wine-cvs mailing list