Skip to content

Commit 7762975

Browse files
j6tgitster
authored andcommitted
Do not use SHELL_PATH from build system in prepare_shell_cmd on Windows
The recent change to use SHELL_PATH instead of "sh" to spawn shell commands is not suited for Windows: - The default setting, "/bin/sh", does not work when git has to run the shell because it is a POSIX style path, but not a proper Windows style path. - If it worked, it would hard-code a position in the files system where the shell is expected, making git (more precisely, the POSIX toolset that is needed alongside git) non-relocatable. But we cannot sacrifice relocatability on Windows. - Apart from that, even though the Makefile leaves SHELL_PATH set to "/bin/sh" for the Windows builds, the build system passes a mangled path to the compiler, and something like "D:/Src/msysgit/bin/sh" is used, which is doubly bad because it points to where /bin/sh resolves to on the system where git was built. - Finally, the system's CreateProcess() function that is used under mingw.c's hood does not work with forward slashes and cannot find the shell. Undo the earlier change on Windows. Signed-off-by: Johannes Sixt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent b3e34dd commit 7762975

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

run-command.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,11 @@ static const char **prepare_shell_cmd(const char **argv)
9494
die("BUG: shell command is empty");
9595

9696
if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
97+
#ifndef WIN32
9798
nargv[nargc++] = SHELL_PATH;
99+
#else
100+
nargv[nargc++] = "sh";
101+
#endif
98102
nargv[nargc++] = "-c";
99103

100104
if (argc < 2)

0 commit comments

Comments
 (0)