Commit 4e10456b authored by Jason Edmeades's avatar Jason Edmeades Committed by Alexandre Julliard

cmd: Ensure current directory saved during cmd /c.

parent c55cd876
......@@ -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);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment