Skip to content

Commit bedc427

Browse files
peterhgitster
authored andcommitted
MinGW: Scan for \r in addition to \n when reading shbang lines
\r is common on Windows, so we should handle it gracefully. Signed-off-by: Steffen Prohaska <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7f5a68a commit bedc427

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

compat/mingw.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,8 +525,8 @@ static const char *parse_interpreter(const char *cmd)
525525
if (buf[0] != '#' || buf[1] != '!')
526526
return NULL;
527527
buf[n] = '\0';
528-
p = strchr(buf, '\n');
529-
if (!p)
528+
p = buf + strcspn(buf, "\r\n");
529+
if (!*p)
530530
return NULL;
531531

532532
*p = '\0';

0 commit comments

Comments
 (0)