From 3077c83763853b703f52c1279e6d5a7e7e179599 Mon Sep 17 00:00:00 2001 From: Johannes Sixt Date: Wed, 28 Feb 2007 11:38:16 +0100 Subject: [PATCH] Really run scripts under the interpreter specified in the first line. Earlier we would have run all scripts under 'sh', but only changed the name (argv[0]) to the parsed interpreter. While we are here, also ignore command line options specified in the interpreter line; perl's -w is the common case. --- compat/mingw.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/compat/mingw.c b/compat/mingw.c index 70a8e1f78f..dbc13f0c8a 100644 --- a/compat/mingw.c +++ b/compat/mingw.c @@ -230,7 +230,7 @@ void quote_argv(const char **dst, const char **src) const char *parse_interpreter(const char *cmd) { static char buf[100]; - char *p; + char *p, *opt; int n, fd; /* don't even try a .exe */ @@ -256,6 +256,9 @@ const char *parse_interpreter(const char *cmd) *p = '\0'; if (!(p = strrchr(buf+2, '/')) && !(p = strrchr(buf+2, '\\'))) return NULL; + /* strip options */ + if ((opt = strchr(p+1, ' '))) + *opt = '\0'; return p+1; } @@ -278,7 +281,7 @@ static int try_shell_exec(const char *cmd, const char **argv, const char **env) sh_argv[0] = interpr; sh_argv[1] = cmd; quote_argv(&sh_argv[2], &argv[1]); - n = spawnvpe(_P_WAIT, "sh", sh_argv, env); + n = spawnvpe(_P_WAIT, interpr, sh_argv, env); if (n == -1) return 1; /* indicate that we tried but failed */ exit(n);