From 0d6ddf59775b4e1e3a1f5e78490c5c2acf46a986 Mon Sep 17 00:00:00 2001 From: Ron Yorston <rmy@pobox.com> Date: Thu, 3 May 2012 14:51:59 +0100 Subject: mingw32: allow whitespace after '#!' in shell scripts --- win32/process.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/win32/process.c b/win32/process.c index b95e173e1..0db1a455a 100644 --- a/win32/process.c +++ b/win32/process.c @@ -57,6 +57,10 @@ parse_interpreter(const char *cmd, char ***opts, int *nopts) if (n < 4) /* at least '#!/x' and not error */ return NULL; + /* + * See http://www.in-ulm.de/~mascheck/various/shebang/ for trivia + * relating to '#!'. + */ if (buf[0] != '#' || buf[1] != '!') return NULL; buf[n] = '\0'; @@ -70,8 +74,12 @@ parse_interpreter(const char *cmd, char ***opts, int *nopts) *p = '\0'; } + /* skip whitespace after '#!' */ + for ( s=buf+2; *s && isspace(*s); ++s ) { + } + /* move to end of interpreter path (which may not contain spaces) */ - for ( s=buf+2; *s && !isspace(*s); ++s ) { + for ( ; *s && !isspace(*s); ++s ) { } n = 0; -- cgit v1.2.3-55-g6feb