MinGW: Scan for \r in addition to \n when reading shbang lines
authorPeter Harris <git@peter.is-a-geek.org>
Sat, 23 May 2009 08:04:47 +0000 (10:04 +0200)
committerJunio C Hamano <gitster@pobox.com>
Sat, 23 May 2009 08:54:45 +0000 (01:54 -0700)
\r is common on Windows, so we should handle it gracefully.

Signed-off-by: Steffen Prohaska <prohaska@zib.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
compat/mingw.c

index cdeda1d9859fd545950e0c39ee7de3c9dc09bb07..b723c4dfd63ef3021e47419bd2dbe570b8ec7b11 100644 (file)
@@ -525,8 +525,8 @@ static const char *parse_interpreter(const char *cmd)
        if (buf[0] != '#' || buf[1] != '!')
                return NULL;
        buf[n] = '\0';
-       p = strchr(buf, '\n');
-       if (!p)
+       p = buf + strcspn(buf, "\r\n");
+       if (!*p)
                return NULL;
 
        *p = '\0';