Skip to content

Commit 0593c1e

Browse files
dschogitster
authored andcommitted
run-command: refactor getting the Unix shell path into its own function
This encapsulates the platform-specific logic better. Signed-off-by: Johannes Schindelin <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a7dae3b commit 0593c1e

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

run-command.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -274,17 +274,22 @@ int sane_execvp(const char *file, char * const argv[])
274274
return -1;
275275
}
276276

277+
static const char *git_shell_path(void)
278+
{
279+
#ifndef GIT_WINDOWS_NATIVE
280+
return SHELL_PATH;
281+
#else
282+
return "sh";
283+
#endif
284+
}
285+
277286
static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
278287
{
279288
if (!argv[0])
280289
BUG("shell command is empty");
281290

282291
if (strcspn(argv[0], "|&;<>()$`\\\"' \t\n*?[#~=%") != strlen(argv[0])) {
283-
#ifndef GIT_WINDOWS_NATIVE
284-
strvec_push(out, SHELL_PATH);
285-
#else
286-
strvec_push(out, "sh");
287-
#endif
292+
strvec_push(out, git_shell_path());
288293
strvec_push(out, "-c");
289294

290295
/*

0 commit comments

Comments
 (0)