Skip to content

Commit ce164e0

Browse files
committed
Merge branch 'spawn-with-spaces'
This change lets us spawn .bat scripts whose paths contain spaces. Signed-off-by: Johannes Schindelin <[email protected]>
2 parents 9e5911f + 4d9b60e commit ce164e0

File tree

2 files changed

+11
-3
lines changed

2 files changed

+11
-3
lines changed

compat/mingw.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1654,7 +1654,9 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
16541654
si.hStdError = winansi_get_osfhandle(fherr);
16551655

16561656
/* executables and the current directory don't support long paths */
1657-
if (xutftowcs_path(wcmd, cmd) < 0)
1657+
if (*argv && !strcmp(cmd, *argv))
1658+
wcmd[0] = L'\0';
1659+
else if (xutftowcs_path(wcmd, cmd) < 0)
16581660
return -1;
16591661
if (dir && xutftowcs_path(wdir, dir) < 0)
16601662
return -1;
@@ -1708,8 +1710,8 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
17081710
wenvblk = make_environment_block(deltaenv);
17091711

17101712
memset(&pi, 0, sizeof(pi));
1711-
ret = CreateProcessW(wcmd, wargs, NULL, NULL, TRUE, flags,
1712-
wenvblk, dir ? wdir : NULL, &si, &pi);
1713+
ret = CreateProcessW(*wcmd ? wcmd : NULL, wargs, NULL, NULL, TRUE,
1714+
flags, wenvblk, dir ? wdir : NULL, &si, &pi);
17131715

17141716
free(wenvblk);
17151717
free(wargs);

t/t0061-run-command.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -210,4 +210,10 @@ test_expect_success MINGW 'verify curlies are quoted properly' '
210210
test_cmp expect actual
211211
'
212212

213+
test_expect_success MINGW 'can spawn with argv[0] containing spaces' '
214+
cp "$GIT_BUILD_DIR/t/helper/test-fake-ssh$X" ./ &&
215+
test_must_fail "$PWD/test-fake-ssh$X" 2>err &&
216+
grep TRASH_DIRECTORY err
217+
'
218+
213219
test_done

0 commit comments

Comments
 (0)