From 2952476e8e9e4b0f455e1569a29e0d3930ee84b2 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Fri, 2 Nov 2007 21:38:57 +0100 Subject: [PATCH] Reimplement execvp() such that it can invoke shell scripts. We conveniently reuse mingw_execve(), which does the shbang interpretation as well as other painful Windows compatibility stuff. --- compat/mingw.c | 14 ++++++++++++++ git-compat-util.h | 2 ++ 2 files changed, 16 insertions(+) diff --git a/compat/mingw.c b/compat/mingw.c index 4b05718f03..4e1003442d 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -529,6 +529,20 @@ void mingw_free_path_split(char **path) free(path); } +void mingw_execvp(const char *cmd, const char **argv) +{ + char **path = mingw_get_path_split(); + char *prog = mingw_path_lookup(cmd, path); + + if (prog) { + mingw_execve(prog, argv, (const char **) environ); + free(prog); + } else + errno = ENOENT; + + mingw_free_path_split(path); +} + int mingw_socket(int domain, int type, int protocol) { SOCKET s = WSASocket(domain, type, protocol, NULL, 0, 0); diff --git a/git-compat-util.h b/git-compat-util.h index f6deba520b..148b64ab04 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -430,6 +430,8 @@ unsigned int alarm(unsigned int seconds); #include void mingw_execve(const char *cmd, const char **argv, const char **env); #define execve mingw_execve +extern void mingw_execvp(const char *cmd, const char **argv); +#define execvp mingw_execvp int fork(); typedef int pid_t; #define waitpid(pid, status, options) \