summaryrefslogtreecommitdiff
path: root/bin/ksh/exec.c
diff options
context:
space:
mode:
authorkamil <kamil@NetBSD.org>2017-06-22 13:33:39 +0000
committerkamil <kamil@NetBSD.org>2017-06-22 13:33:39 +0000
commit7f4c58acba21577034f6f4789b0451bc80ea94fd (patch)
tree5d807799a22ddec34dfed147eb3eac65729fe962 /bin/ksh/exec.c
parent67a317c8e065fad4a97d4384fe84cb759cf65077 (diff)
Remove os2 support in ksh(1)
OK by <kre>
Diffstat (limited to 'bin/ksh/exec.c')
-rw-r--r--bin/ksh/exec.c150
1 files changed, 3 insertions, 147 deletions
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index 93c1aa25726..1205f4db06b 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $NetBSD: exec.c,v 1.15 2012/03/25 17:23:48 christos Exp $ */
+/* $NetBSD: exec.c,v 1.16 2017/06/22 13:33:39 kamil Exp $ */
/*
* execute command tree
@@ -6,7 +6,7 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: exec.c,v 1.15 2012/03/25 17:23:48 christos Exp $");
+__RCSID("$NetBSD: exec.c,v 1.16 2017/06/22 13:33:39 kamil Exp $");
#endif
@@ -38,10 +38,6 @@ static int dbteste_eval ARGS((Test_env *, Test_op, const char *,
const char *, int));
static void dbteste_error ARGS((Test_env *, int, const char *));
#endif /* KSH */
-#ifdef OS2
-static int search_access1 ARGS((const char *, int, int *));
-#endif /* OS2 */
-
/*
* handle systems that don't have F_SETFD
@@ -424,8 +420,7 @@ execute(t, flags)
#endif
restoresigs();
cleanup_proc_env();
- /* XINTACT bit is for OS2 */
- ksh_execve(t->str, t->args, ap, (flags & XINTACT) ? 1 : 0);
+ ksh_execve(t->str, t->args, ap, flags);
if (errno == ENOEXEC)
scriptexec(t, ap);
else
@@ -782,32 +777,16 @@ scriptexec(tp, ap)
(void) close(fd);
}
if ((buf[0] == '#' && buf[1] == '!' && (cp = &buf[2]))
-# ifdef OS2
- || (strncmp(buf, "extproc", 7) == 0 && isspace((unsigned char)buf[7])
- && (cp = &buf[7]))
-# endif /* OS2 */
)
{
while (*cp && (*cp == ' ' || *cp == '\t'))
cp++;
if (*cp && *cp != '\n') {
char *a0 = cp, *a1 = (char *) 0;
-# ifdef OS2
- char *a2 = cp;
-# endif /* OS2 */
while (*cp && *cp != '\n' && *cp != ' '
&& *cp != '\t')
{
-# ifdef OS2
- /* Allow shell search without prepended path
- * if shell with / in pathname cannot be found.
- * Use / explicitly so \ can be used if explicit
- * needs to be forced.
- */
- if (*cp == '/')
- a2 = cp + 1;
-# endif /* OS2 */
cp++;
}
if (*cp && *cp != '\n') {
@@ -826,38 +805,9 @@ scriptexec(tp, ap)
*cp = '\0';
if (a1)
*tp->args-- = a1;
-# ifdef OS2
- if (a0 != a2) {
- char *tmp_a0 = str_nsave(a0,
- strlen(a0) + 5, ATEMP);
- if (search_access(tmp_a0, X_OK,
- (int *) 0))
- a0 = a2;
- afree(tmp_a0, ATEMP);
- }
-# endif /* OS2 */
shellv = a0;
}
}
-# ifdef OS2
- } else {
- /* Use ksh documented shell default if present
- * else use OS2_SHELL which is assumed to need
- * the /c option and '\' as dir separator.
- */
- char *p = shellv;
-
- shellv = str_val(global("EXECSHELL"));
- if (shellv && *shellv)
- shellv = search(shellv, path, X_OK, (int *) 0);
- if (!shellv || !*shellv) {
- shellv = p;
- *tp->args-- = "/c";
- for (p = tp->str; *p; p++)
- if (*p == '/')
- *p = '\\';
- }
-# endif /* OS2 */
}
}
#endif /* SHARPBANG */
@@ -1116,7 +1066,6 @@ search_access(pathx, mode, errnop)
int mode;
int *errnop; /* set if candidate found, but not suitable */
{
-#ifndef OS2
int ret, err = 0;
struct stat statb;
@@ -1136,73 +1085,7 @@ search_access(pathx, mode, errnop)
if (err && errnop && !*errnop)
*errnop = err;
return ret;
-#else /* !OS2 */
- /*
- * NOTE: ASSUMES path can be modified and has enough room at the
- * end of the string for a suffix (ie, 4 extra characters).
- * Certain code knows this (eg, eval.c(globit()),
- * exec.c(search())).
- */
- static char *xsuffixes[] = { ".ksh", ".exe", ".", ".sh", ".cmd",
- ".com", ".bat", (char *) 0
- };
- static char *rsuffixes[] = { ".ksh", ".", ".sh", ".cmd", ".bat",
- (char *) 0
- };
- int i;
- char *mpath = (char *) pathx;
- char *tp = mpath + strlen(mpath);
- char *p;
- char **sfx;
-
- /* If a suffix has been specified, check if it is one of the
- * suffixes that indicate the file is executable - if so, change
- * the access test to R_OK...
- * This code assumes OS/2 files can have only one suffix...
- */
- if ((p = strrchr((p = ksh_strrchr_dirsep(mpath)) ? p : mpath, '.'))) {
- if (mode == X_OK)
- mode = R_OK;
- return search_access1(mpath, mode, errnop);
- }
- /* Try appending the various suffixes. Different suffixes for
- * read and execute 'cause we don't want to read an executable...
- */
- sfx = mode == R_OK ? rsuffixes : xsuffixes;
- for (i = 0; sfx[i]; i++) {
- strcpy(tp, p = sfx[i]);
- if (search_access1(mpath, R_OK, errnop) == 0)
- return 0;
- *tp = '\0';
- }
- return -1;
-#endif /* !OS2 */
-}
-
-#ifdef OS2
-static int
-search_access1(pathx, mode, errnop)
- const char *pathx;
- int mode;
- int *errnop; /* set if candidate found, but not suitable */
-{
- int ret, err = 0;
- struct stat statb;
-
- if (stat(pathx, &statb) < 0)
- return -1;
- ret = eaccess(pathx, mode);
- if (ret < 0)
- err = errno; /* File exists, but we can't access it */
- else if (!S_ISREG(statb.st_mode)) {
- ret = -1;
- err = S_ISDIR(statb.st_mode) ? EISDIR : EACCES;
- }
- if (err && errnop && !*errnop)
- *errnop = err;
- return ret;
}
-#endif /* OS2 */
/*
* search for command with PATH
@@ -1221,25 +1104,7 @@ search(name, pathx, mode, errnop)
if (errnop)
*errnop = 0;
-#ifdef OS2
- /* Xinit() allocates 8 additional bytes, so appended suffixes won't
- * overflow the memory.
- */
- namelen = strlen(name) + 1;
- Xinit(xs, xp, namelen, ATEMP);
- memcpy(Xstring(xs, xp), name, namelen);
-
- if (ksh_strchr_dirsep(name)) {
- if (search_access(Xstring(xs, xp), mode, errnop) >= 0)
- return Xstring(xs, xp); /* not Xclose() - see above */
- Xfree(xs, xp);
- return NULL;
- }
- /* Look in current context always. (os2 style) */
- if (search_access(Xstring(xs, xp), mode, errnop) == 0)
- return Xstring(xs, xp); /* not Xclose() - xp may be wrong */
-#else /* OS2 */
if (ksh_strchr_dirsep(name)) {
if (search_access(name, mode, errnop) == 0)
return (char *)__UNCONST(name);
@@ -1248,7 +1113,6 @@ search(name, pathx, mode, errnop)
namelen = strlen(name) + 1;
Xinit(xs, xp, 128, ATEMP);
-#endif /* OS2 */
sp = pathx;
while (sp != NULL) {
@@ -1265,11 +1129,7 @@ search(name, pathx, mode, errnop)
XcheckN(xs, xp, namelen);
memcpy(xp, name, namelen);
if (search_access(Xstring(xs, xp), mode, errnop) == 0)
-#ifdef OS2
- return Xstring(xs, xp); /* Not Xclose() - see above */
-#else /* OS2 */
return Xclose(xs, xp + namelen);
-#endif /* OS2 */
if (*sp++ == '\0')
sp = NULL;
}
@@ -1382,10 +1242,6 @@ iosetup(iop, tp)
return -1;
}
u = open(cp, flags, 0666);
-#ifdef OS2
- if (u < 0 && strcmp(cp, "/dev/null") == 0)
- u = open("nul", flags, 0666);
-#endif /* OS2 */
}
if (u < 0) {
/* herein() may already have printed message */