Commit 60fe4dae authored by Dan Kegel's avatar Dan Kegel Committed by Alexandre Julliard

cmd: %~dp0 should expand to the directory containing the batch file, not the current directory.

parent 4509d9aa
...@@ -91,6 +91,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN ...@@ -91,6 +91,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN
prev_context = context; prev_context = context;
context = LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT)); context = LocalAlloc (LMEM_FIXED, sizeof (BATCH_CONTEXT));
context -> h = h; context -> h = h;
context->batchfileW = WCMD_strdupW(string);
context -> command = command; context -> command = command;
memset(context -> shift_count, 0x00, sizeof(context -> shift_count)); memset(context -> shift_count, 0x00, sizeof(context -> shift_count));
context -> prev_context = prev_context; context -> prev_context = prev_context;
...@@ -122,6 +123,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN ...@@ -122,6 +123,7 @@ void WCMD_batch (WCHAR *file, WCHAR *command, int called, WCHAR *startLabel, HAN
* to the caller's caller. * to the caller's caller.
*/ */
HeapFree(GetProcessHeap(), 0, context->batchfileW);
LocalFree (context); LocalFree (context);
if ((prev_context != NULL) && (!called)) { if ((prev_context != NULL) && (!called)) {
prev_context -> skip_rest = TRUE; prev_context -> skip_rest = TRUE;
...@@ -382,7 +384,9 @@ void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValu ...@@ -382,7 +384,9 @@ void WCMD_HandleTildaModifiers(WCHAR **start, WCHAR *forVariable, WCHAR *forValu
if (lastModifier == firstModifier) return; /* Invalid syntax */ if (lastModifier == firstModifier) return; /* Invalid syntax */
/* Extract the parameter to play with */ /* Extract the parameter to play with */
if ((*lastModifier >= '0' && *lastModifier <= '9')) { if (*lastModifier == '0') {
strcpyW(outputparam, context->batchfileW);
} else if ((*lastModifier >= '1' && *lastModifier <= '9')) {
strcpyW(outputparam, WCMD_parameter (context -> command, strcpyW(outputparam, WCMD_parameter (context -> command,
*lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL)); *lastModifier-'0' + context -> shift_count[*lastModifier-'0'], NULL));
} else { } else {
......
...@@ -118,6 +118,7 @@ void WCMD_execute (WCHAR *orig_command, WCHAR *redirects, WCHAR *parameter, ...@@ -118,6 +118,7 @@ void WCMD_execute (WCHAR *orig_command, WCHAR *redirects, WCHAR *parameter,
typedef struct { typedef struct {
WCHAR *command; /* The command which invoked the batch file */ WCHAR *command; /* The command which invoked the batch file */
HANDLE h; /* Handle to the open batch file */ HANDLE h; /* Handle to the open batch file */
WCHAR *batchfileW; /* Name of same */
int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */ int shift_count[10]; /* Offset in terms of shifts for %0 - %9 */
void *prev_context; /* Pointer to the previous context block */ void *prev_context; /* Pointer to the previous context block */
BOOL skip_rest; /* Skip the rest of the batch program and exit */ BOOL skip_rest; /* Skip the rest of the batch program and exit */
......
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