also accept a carriage return as end of shebang line;

helps to at least not get messages like
| sysop@odem2k:~/mb $ ./foo.sh
| : No such file or directory
| 127|sysop@odem2k:~/mb $ _
if you forgot to convert CR-LF into LF (of course only if the
kernel fails with ENOEXEC – an ENOENT would not help in these
cases), but of course other things will fail
This commit is contained in:
tg 2007-04-17 21:26:34 +00:00
parent dc71f9b775
commit 12b2011a96
1 changed files with 3 additions and 3 deletions

6
exec.c
View File

@ -2,7 +2,7 @@
#include "sh.h"
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.27 2007/04/15 12:09:57 tg Exp $");
__RCSID("$MirOS: src/bin/mksh/exec.c,v 1.28 2007/04/17 21:26:34 tg Exp $");
static int comexec(struct op *, struct tbl *volatile, const char **,
int volatile);
@ -693,10 +693,10 @@ scriptexec(struct op *tp, const char **ap)
/* read error -> no good */
buf[0] = '\0';
close(fd);
/* scan for newline or NUL _before_ end of buffer */
/* scan for newline (or CR) or NUL _before_ end of buffer */
cp = (unsigned char *)buf;
while ((char *)cp < (buf + sizeof (buf)))
if (*cp == '\0' || *cp == '\n') {
if (*cp == '\0' || *cp == '\n' || *cp == '\r') {
*cp = '\0';
break;
} else