run-command: refactor getting the Unix shell path into its own function
This encapsulates the platform-specific logic better. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
Jul 13, 2024 at 21:08 UTC
0593c1ea30737cf2d61f7c191d3687b37badf3be
1 file changed
+10
-5
run-command.c
+10
-5
@@ -274,17 +274,22 @@ int sane_execvp(const char *file, char * const argv[])
274
return -1;
275
}
276
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
+
286
static const char **prepare_shell_cmd(struct strvec *out, const char **argv)
287
{
288
if (!argv[0])
289
BUG("shell command is empty");
290
291
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());
293
strvec_push(out, "-c");
294
295
/*