ksh: Drop support for systems without handling shebang

This commit is contained in:
kamil 2017-06-30 02:06:59 +00:00
parent 5c93126131
commit 51ebc97c9d
3 changed files with 5 additions and 62 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: config.h,v 1.41 2017/06/30 02:02:41 kamil Exp $ */
/* $NetBSD: config.h,v 1.42 2017/06/30 02:06:59 kamil Exp $ */
/* config.h. Generated automatically by configure. */
/* config.h.in. Generated automatically from configure.in by autoheader. */
@ -36,9 +36,6 @@
/* Define if you can safely include both <sys/time.h> and <time.h>. */
#define TIME_WITH_SYS_TIME 1
/* Define if your kernel doesn't handle scripts starting with #! */
/* #undef SHARPBANG */
/* Define as the return value of signal handlers (0 or ). */
#define RETSIGVAL

View File

@ -1,4 +1,4 @@
/* $NetBSD: eval.c,v 1.19 2017/06/22 14:20:46 kamil Exp $ */
/* $NetBSD: eval.c,v 1.20 2017/06/30 02:06:59 kamil Exp $ */
/*
* Expansion - quoting, separation, substitution, globbing
@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: eval.c,v 1.19 2017/06/22 14:20:46 kamil Exp $");
__RCSID("$NetBSD: eval.c,v 1.20 2017/06/30 02:06:59 kamil Exp $");
#endif
#include <stdint.h>
@ -95,17 +95,10 @@ eval(ap, f)
return ap;
XPinit(w, 32);
XPput(w, NULL); /* space for shell name */
#ifdef SHARPBANG
XPput(w, NULL); /* and space for one arg */
#endif
while (*ap != NULL)
expand(*ap++, &w, f);
XPput(w, NULL);
#ifdef SHARPBANG
return (char **) XPclose(w) + 2;
#else
return (char **) XPclose(w) + 1;
#endif
}
/*

View File

@ -1,4 +1,4 @@
/* $NetBSD: exec.c,v 1.19 2017/06/22 23:47:29 kamil Exp $ */
/* $NetBSD: exec.c,v 1.20 2017/06/30 02:06:59 kamil Exp $ */
/*
* execute command tree
@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: exec.c,v 1.19 2017/06/22 23:47:29 kamil Exp $");
__RCSID("$NetBSD: exec.c,v 1.20 2017/06/30 02:06:59 kamil Exp $");
#endif
@ -764,53 +764,6 @@ scriptexec(tp, ap)
shellv = __UNCONST(EXECSHELL);
*tp->args-- = tp->str;
#ifdef SHARPBANG
{
char buf[LINE];
register char *cp;
register int fd, n;
buf[0] = '\0';
if ((fd = open(tp->str, O_RDONLY)) >= 0) {
if ((n = read(fd, buf, LINE - 1)) > 0)
buf[n] = '\0';
(void) close(fd);
}
if ((buf[0] == '#' && buf[1] == '!' && (cp = &buf[2]))
)
{
while (*cp && (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
char *a0 = cp, *a1 = (char *) 0;
while (*cp && *cp != '\n' && *cp != ' '
&& *cp != '\t')
{
cp++;
}
if (*cp && *cp != '\n') {
*cp++ = '\0';
while (*cp
&& (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
a1 = cp;
/* all one argument */
while (*cp && *cp != '\n')
cp++;
}
}
if (*cp == '\n') {
*cp = '\0';
if (a1)
*tp->args-- = a1;
shellv = a0;
}
}
}
}
#endif /* SHARPBANG */
*tp->args = shellv;
execve(tp->args[0], tp->args, ap);