@@ -124,7 +124,7 @@ static void setup_environment(LPWSTR top_level_path, int full_path)
124
124
*/
125
125
static LPWSTR fixup_commandline (LPWSTR exepath , LPWSTR * exep , int * wait ,
126
126
LPWSTR prefix_args , int prefix_args_len , int is_git_command ,
127
- int skip_arguments )
127
+ int skip_arguments , int append_quote_to_cmdline )
128
128
{
129
129
int wargc = 0 ;
130
130
LPWSTR cmd = NULL , cmdline = NULL ;
@@ -133,7 +133,8 @@ static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
133
133
cmdline = GetCommandLine ();
134
134
wargv = CommandLineToArgvW (cmdline , & wargc );
135
135
cmd = (LPWSTR )malloc (sizeof (WCHAR ) *
136
- (wcslen (cmdline ) + prefix_args_len + 1 + MAX_PATH ));
136
+ (wcslen (cmdline ) + prefix_args_len + 1 + MAX_PATH +
137
+ append_quote_to_cmdline ));
137
138
if (prefix_args ) {
138
139
if (is_git_command )
139
140
_swprintf (cmd , L"\"%s\\%s\" %.*s" , exepath , L"git.exe" ,
@@ -164,6 +165,9 @@ static LPWSTR fixup_commandline(LPWSTR exepath, LPWSTR *exep, int *wait,
164
165
wcscat (cmd , p );
165
166
}
166
167
168
+ if (append_quote_to_cmdline )
169
+ wcscat (cmd , L"\"" );
170
+
167
171
if (wargc > 1 && !wcscmp (wargv [1 ], L"gui" ))
168
172
* wait = 0 ;
169
173
@@ -285,9 +289,11 @@ static void set_app_id(LPWSTR app_id)
285
289
static int configure_via_resource (LPWSTR basename , LPWSTR exepath , LPWSTR exep ,
286
290
LPWSTR * prefix_args , int * prefix_args_len ,
287
291
int * is_git_command , LPWSTR * working_directory , int * full_path ,
288
- int * skip_arguments , int * allocate_console , int * show_console )
292
+ int * skip_arguments , int * allocate_console , int * show_console ,
293
+ int * append_quote_to_cmdline )
289
294
{
290
295
int i , id , minimal_search_path , needs_a_console , no_hide , wargc ;
296
+ int append_quote ;
291
297
LPWSTR * wargv ;
292
298
WCHAR * app_id ;
293
299
@@ -300,6 +306,7 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
300
306
minimal_search_path = 0 ;
301
307
needs_a_console = 0 ;
302
308
no_hide = 0 ;
309
+ append_quote = 0 ;
303
310
app_id = NULL ;
304
311
len = LoadString (NULL , id , buf , BUFSIZE );
305
312
@@ -325,6 +332,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
325
332
needs_a_console = 1 ;
326
333
else if (strip_prefix (buf , & len , L"SHOW_CONSOLE=1 " ))
327
334
no_hide = 1 ;
335
+ else if (strip_prefix (buf , & len , L"APPEND_QUOTE=1 " ))
336
+ append_quote = 1 ;
328
337
else if (strip_prefix (buf , & len , L"APP_ID=" )) {
329
338
LPWSTR space = wcschr (buf , L' ' );
330
339
size_t app_id_len = space - buf ;
@@ -386,6 +395,10 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
386
395
no_hide = 0 ;
387
396
else if (!wcscmp (L"--no-hide" , wargv [i ]))
388
397
no_hide = 1 ;
398
+ else if (!wcscmp (L"--append-quote" , wargv [i ]))
399
+ append_quote = 1 ;
400
+ else if (!wcscmp (L"--no-append-quote" , wargv [i ]))
401
+ append_quote = -1 ;
389
402
else if (!wcsncmp (L"--command=" , wargv [i ], 10 )) {
390
403
LPWSTR expanded ;
391
404
@@ -415,6 +428,8 @@ static int configure_via_resource(LPWSTR basename, LPWSTR exepath, LPWSTR exep,
415
428
* allocate_console = 1 ;
416
429
if (no_hide )
417
430
* show_console = 1 ;
431
+ if (append_quote )
432
+ * append_quote_to_cmdline = append_quote == 1 ;
418
433
if (app_id )
419
434
set_app_id (app_id );
420
435
LocalFree (wargv );
@@ -466,7 +481,8 @@ int main(void)
466
481
{
467
482
int r = 1 , wait = 1 , prefix_args_len = -1 , needs_env_setup = 1 ,
468
483
is_git_command = 1 , full_path = 1 , skip_arguments = 0 ,
469
- allocate_console = 0 , show_console = 0 ;
484
+ allocate_console = 0 , show_console = 0 ,
485
+ append_quote_to_cmdline = 0 ;
470
486
WCHAR exepath [MAX_PATH ], exe [MAX_PATH ], top_level_path [MAX_PATH ];
471
487
LPWSTR cmd = NULL , exep = exe , prefix_args = NULL , basename ;
472
488
LPWSTR working_directory = NULL ;
@@ -487,7 +503,7 @@ int main(void)
487
503
& prefix_args , & prefix_args_len ,
488
504
& is_git_command , & working_directory ,
489
505
& full_path , & skip_arguments , & allocate_console ,
490
- & show_console )) {
506
+ & show_console , & append_quote_to_cmdline )) {
491
507
/* do nothing */
492
508
}
493
509
else if (!wcsicmp (basename , L"git-gui.exe" )) {
@@ -571,7 +587,8 @@ int main(void)
571
587
setup_environment (top_level_path , full_path );
572
588
}
573
589
cmd = fixup_commandline (exepath , & exep , & wait ,
574
- prefix_args , prefix_args_len , is_git_command , skip_arguments );
590
+ prefix_args , prefix_args_len , is_git_command , skip_arguments ,
591
+ append_quote_to_cmdline );
575
592
576
593
if (working_directory == (LPWSTR )1 ) {
577
594
int len = GetEnvironmentVariable (L"HOME" , NULL , 0 );
0 commit comments