MCPcopy Create free account
hub / github.com/git/git / try_shell_exec

Function try_shell_exec

compat/mingw.c:2184–2216  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2182}
2183
2184static int try_shell_exec(const char *cmd, char *const *argv)
2185{
2186 const char *interpr = parse_interpreter(cmd);
2187 char *prog;
2188 int pid = 0;
2189
2190 if (!interpr)
2191 return 0;
2192 prog = path_lookup(interpr, 1);
2193 if (prog) {
2194 int exec_id;
2195 int argc = 0;
2196 char **argv2;
2197 while (argv[argc]) argc++;
2198 ALLOC_ARRAY(argv2, argc + 1);
2199 argv2[0] = (char *)cmd; /* full path to the script file */
2200 COPY_ARRAY(&argv2[1], &argv[1], argc);
2201 exec_id = trace2_exec(prog, (const char **)argv2);
2202 pid = mingw_spawnv(prog, (const char **)argv2, 1);
2203 if (pid >= 0) {
2204 int status;
2205 if (waitpid(pid, &status, 0) < 0)
2206 status = 255;
2207 trace2_exec_result(exec_id, status);
2208 exit(status);
2209 }
2210 trace2_exec_result(exec_id, -1);
2211 pid = 1; /* indicate that we tried but failed */
2212 free(prog);
2213 free(argv2);
2214 }
2215 return pid;
2216}
2217
2218int mingw_execv(const char *cmd, char *const *argv)
2219{

Callers 1

mingw_execvFunction · 0.85

Calls 4

parse_interpreterFunction · 0.85
path_lookupFunction · 0.85
mingw_spawnvFunction · 0.85
waitpidFunction · 0.85

Tested by

no test coverage detected