unifdef: KSH
no binary change
This commit is contained in:
parent
6d8b225141
commit
4c4a9323f8
4
Build.sh
4
Build.sh
@ -1,5 +1,5 @@
|
||||
#!/bin/sh
|
||||
# $MirBSD: src/bin/ksh/Build.sh,v 2.3 2004/12/13 18:53:25 tg Exp $
|
||||
# $MirBSD: src/bin/ksh/Build.sh,v 2.4 2004/12/18 18:58:30 tg Exp $
|
||||
#-
|
||||
# Copyright (c) 2004
|
||||
# Thorsten "mirabile" Glaser <tg@66h.42h.de>
|
||||
@ -36,7 +36,7 @@
|
||||
SHELL="${SHELL:-/bin/sh}"; export SHELL
|
||||
CONFIG_SHELL="${SHELL}"; export CONFIG_SHELL
|
||||
CC="${CC:-gcc}"
|
||||
CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H -I. -DKSH"
|
||||
CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H -I."
|
||||
COPTS="-O2 -fomit-frame-pointer -fno-strict-aliasing -fno-strength-reduce"
|
||||
[ -z "$WEIRD_OS" ] && LDFLAGS="${LDFLAGS:--static}"
|
||||
|
||||
|
4
Makefile
4
Makefile
@ -1,4 +1,4 @@
|
||||
# $MirBSD: src/bin/ksh/Makefile,v 2.3 2004/12/13 18:53:25 tg Exp $
|
||||
# $MirBSD: src/bin/ksh/Makefile,v 2.4 2004/12/18 18:58:30 tg Exp $
|
||||
# $OpenBSD: Makefile,v 1.18 2004/02/16 19:07:19 deraadt Exp $
|
||||
|
||||
PROG= ksh
|
||||
@ -7,7 +7,7 @@ SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
|
||||
path.c shf.c syn.c table.c trap.c tree.c tty.c var.c vi.c
|
||||
MAN= ksh.1tbl sh.1tbl
|
||||
|
||||
CPPFLAGS+= -DHAVE_CONFIG_H -I. -DKSH -DMIRBSD_NATIVE
|
||||
CPPFLAGS+= -DHAVE_CONFIG_H -I. -DMIRBSD_NATIVE
|
||||
CFLAGS+= -Wall -Werror -W -pedantic
|
||||
CLEANFILES+= siglist.out emacs.out
|
||||
|
||||
|
26
c_ksh.c
26
c_ksh.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.2 2004/12/13 19:05:08 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/c_ksh.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: c_ksh.c,v 1.18 2004/02/10 13:03:36 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -13,7 +13,7 @@
|
||||
#include <sys/cygwin.h>
|
||||
#endif /* __CYGWIN__ */
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.2 2004/12/13 19:05:08 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 2.3 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
int
|
||||
c_cd(char **wp)
|
||||
@ -274,14 +274,12 @@ c_print(char **wp)
|
||||
case 'n':
|
||||
flags &= ~PO_NL;
|
||||
break;
|
||||
#ifdef KSH
|
||||
case 'p':
|
||||
if ((fd = coproc_getfd(W_OK, &emsg)) < 0) {
|
||||
bi_errorf("-p: %s", emsg);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
#endif /* KSH */
|
||||
case 'r':
|
||||
flags &= ~PO_EXPAND;
|
||||
break;
|
||||
@ -368,7 +366,6 @@ c_print(char **wp)
|
||||
} else {
|
||||
int n, len = Xlength(xs, xp);
|
||||
int UNINITIALIZED(opipe);
|
||||
#ifdef KSH
|
||||
|
||||
/* Ensure we aren't killed by a SIGPIPE while writing to
|
||||
* a coprocess. at&t ksh doesn't seem to do this (seems
|
||||
@ -379,40 +376,25 @@ c_print(char **wp)
|
||||
flags |= PO_COPROC;
|
||||
opipe = block_pipe();
|
||||
}
|
||||
#endif /* KSH */
|
||||
for (s = Xstring(xs, xp); len > 0; ) {
|
||||
n = write(fd, s, len);
|
||||
if (n < 0) {
|
||||
#ifdef KSH
|
||||
if (flags & PO_COPROC)
|
||||
restore_pipe(opipe);
|
||||
#endif /* KSH */
|
||||
if (errno == EINTR) {
|
||||
/* allow user to ^C out */
|
||||
intrcheck();
|
||||
#ifdef KSH
|
||||
if (flags & PO_COPROC)
|
||||
opipe = block_pipe();
|
||||
#endif /* KSH */
|
||||
continue;
|
||||
}
|
||||
#ifdef KSH
|
||||
/* This doesn't really make sense - could
|
||||
* break scripts (print -p generates
|
||||
* error message).
|
||||
*if (errno == EPIPE)
|
||||
* coproc_write_close(fd);
|
||||
*/
|
||||
#endif /* KSH */
|
||||
return 1;
|
||||
}
|
||||
s += n;
|
||||
len -= n;
|
||||
}
|
||||
#ifdef KSH
|
||||
if (flags & PO_COPROC)
|
||||
restore_pipe(opipe);
|
||||
#endif /* KSH */
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -1034,7 +1016,6 @@ c_unalias(char **wp)
|
||||
return rv;
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
int
|
||||
c_let(char **wp)
|
||||
{
|
||||
@ -1052,7 +1033,6 @@ c_let(char **wp)
|
||||
rv = val == 0;
|
||||
return rv;
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
int
|
||||
c_jobs(char **wp)
|
||||
@ -1414,9 +1394,7 @@ const struct builtin kshbuiltins [] = {
|
||||
{"+getopts", c_getopts},
|
||||
{"+jobs", c_jobs},
|
||||
{"+kill", c_kill},
|
||||
#ifdef KSH
|
||||
{"let", c_let},
|
||||
#endif /* KSH */
|
||||
{"print", c_print},
|
||||
{"pwd", c_pwd},
|
||||
{"*=readonly", c_typeset},
|
||||
|
12
c_sh.c
12
c_sh.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/c_sh.c,v 2.3 2004/12/13 19:05:08 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/c_sh.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: c_sh.c,v 1.17 2003/03/13 09:03:07 deraadt Exp $ */
|
||||
|
||||
/*
|
||||
@ -10,7 +10,7 @@
|
||||
#include "ksh_time.h"
|
||||
#include "ksh_times.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.3 2004/12/13 19:05:08 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 2.4 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
static char *clocktos(clock_t t);
|
||||
|
||||
@ -250,14 +250,12 @@ c_read(char **wp)
|
||||
|
||||
while ((optc = ksh_getopt(wp, &builtin_opt, "prsu,")) != EOF)
|
||||
switch (optc) {
|
||||
#ifdef KSH
|
||||
case 'p':
|
||||
if ((fd = coproc_getfd(R_OK, &emsg)) < 0) {
|
||||
bi_errorf("-p: %s", emsg);
|
||||
return 1;
|
||||
}
|
||||
break;
|
||||
#endif /* KSH */
|
||||
case 'r':
|
||||
expand = 0;
|
||||
break;
|
||||
@ -297,7 +295,6 @@ c_read(char **wp)
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
/* If we are reading from the co-process for the first time,
|
||||
* make sure the other side of the pipe is closed first. This allows
|
||||
* the detection of eof.
|
||||
@ -308,7 +305,6 @@ c_read(char **wp)
|
||||
* If this call is removed, remove the eof check below, too.
|
||||
* coproc_readw_close(fd);
|
||||
*/
|
||||
#endif /* KSH */
|
||||
|
||||
if (history)
|
||||
Xinit(xs, xp, 128, ATEMP);
|
||||
@ -401,14 +397,12 @@ c_read(char **wp)
|
||||
histsave(source->line, Xstring(xs, xp), 1);
|
||||
Xfree(xs, xp);
|
||||
}
|
||||
#ifdef KSH
|
||||
/* if this is the co-process fd, close the file descriptor
|
||||
* (can get eof if and only if all processes are have died, ie,
|
||||
* coproc.njobs is 0 and the pipe is closed).
|
||||
*/
|
||||
if (c == EOF && !ecode)
|
||||
coproc_read_close(fd);
|
||||
#endif /* KSH */
|
||||
|
||||
return ecode ? ecode : c == EOF;
|
||||
}
|
||||
@ -813,10 +807,8 @@ c_exec(char **wp GCC_FUNC_ATTR(unused))
|
||||
* happens is unspecified and the bourne shell
|
||||
* keeps them open).
|
||||
*/
|
||||
#ifdef KSH
|
||||
if (!Flag(FSH) && i > 2 && e->savefd[i])
|
||||
fd_clexec(i);
|
||||
#endif /* KSH */
|
||||
}
|
||||
e->savefd = NULL;
|
||||
}
|
||||
|
6
c_test.c
6
c_test.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/c_test.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/c_test.c,v 2.2 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: c_test.c,v 1.10 2003/10/10 19:09:07 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -14,7 +14,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include "c_test.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/c_test.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/c_test.c,v 2.2 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
/* test(1) accepts the following grammar:
|
||||
oexpr ::= aexpr | aexpr "-o" oexpr ;
|
||||
@ -72,9 +72,7 @@ static const struct t_op u_ops [] = {
|
||||
};
|
||||
static const struct t_op b_ops [] = {
|
||||
{"=", TO_STEQL },
|
||||
#ifdef KSH
|
||||
{"==", TO_STEQL },
|
||||
#endif /* KSH */
|
||||
{"!=", TO_STNEQ },
|
||||
{"<", TO_STLT },
|
||||
{">", TO_STGT },
|
||||
|
@ -1,12 +1,9 @@
|
||||
/** $MirBSD: src/bin/ksh/conf-end.h,v 2.2 2004/12/18 18:39:10 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/conf-end.h,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: conf-end.h,v 1.2 1996/08/25 12:37:58 downsj Exp $ */
|
||||
|
||||
#ifndef CONF_END_H
|
||||
#define CONF_END_H
|
||||
|
||||
/* Include ksh features? */
|
||||
/* #define KSH 1 */
|
||||
|
||||
/* Include emacs editing? */
|
||||
#define EMACS 1
|
||||
|
||||
@ -26,11 +23,7 @@
|
||||
#define COMPLEX_HISTORY
|
||||
|
||||
/* Strict POSIX behaviour? */
|
||||
#ifdef KSH
|
||||
#undef POSIXLY_CORRECT
|
||||
#else
|
||||
#define POSIXLY_CORRECT 1
|
||||
#endif
|
||||
|
||||
/* Specify default $ENV? */
|
||||
/* #undef DEFAULT_ENV */
|
||||
|
42
exec.c
42
exec.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/exec.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/exec.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
|
||||
|
||||
/*
|
||||
@ -10,14 +10,7 @@
|
||||
#include <ctype.h>
|
||||
#include "ksh_stat.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
|
||||
|
||||
/* Does ps4 get parameter substitutions done? */
|
||||
#ifdef KSH
|
||||
# define PS4_SUBSTITUTE(s) substitute((s), 0)
|
||||
#else
|
||||
# define PS4_SUBSTITUTE(s) (s)
|
||||
#endif /* KSH */
|
||||
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 2.4 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
static int comexec(struct op *t, struct tbl *volatile tp, char **ap,
|
||||
int volatile flags);
|
||||
@ -25,17 +18,13 @@ static void scriptexec(struct op *tp, char **ap);
|
||||
static int call_builtin(struct tbl *tp, char **wp);
|
||||
static int iosetup(struct ioword *iop, struct tbl *tp);
|
||||
static int herein(const char *content, int sub);
|
||||
#ifdef KSH
|
||||
static char *do_selectargs(char **ap, bool_t print_menu);
|
||||
#endif /* KSH */
|
||||
#ifdef KSH
|
||||
static int dbteste_isa(Test_env *te, Test_meta meta);
|
||||
static const char *dbteste_getopnd(Test_env *te, Test_op op,
|
||||
int do_eval);
|
||||
static int dbteste_eval(Test_env *te, Test_op op, const char *opnd1,
|
||||
const char *opnd2, int do_eval);
|
||||
static void dbteste_error(Test_env *te, int offset, const char *msg);
|
||||
#endif /* KSH */
|
||||
|
||||
|
||||
/*
|
||||
@ -118,7 +107,7 @@ execute(struct op *volatile t, volatile int flags)
|
||||
timex_hook(t, &ap);
|
||||
if (Flag(FXTRACE) && ap[0]) {
|
||||
shf_fprintf(shl_out, "%s",
|
||||
PS4_SUBSTITUTE(str_val(global("PS4"))));
|
||||
substitute(str_val(global("PS4")), 0));
|
||||
for (i = 0; ap[i]; i++)
|
||||
shf_fprintf(shl_out, "%s%s", ap[i],
|
||||
ap[i + 1] ? space : newline);
|
||||
@ -196,7 +185,6 @@ execute(struct op *volatile t, volatile int flags)
|
||||
rv = execute(t, flags & XERROK);
|
||||
break;
|
||||
|
||||
#ifdef KSH
|
||||
case TCOPROC:
|
||||
{
|
||||
# ifdef JOB_SIGS
|
||||
@ -261,7 +249,6 @@ execute(struct op *volatile t, volatile int flags)
|
||||
coproc.readw);
|
||||
break;
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
case TASYNC:
|
||||
/* XXX non-optimal, I think - "(foo &)", forks for (),
|
||||
@ -284,7 +271,6 @@ execute(struct op *volatile t, volatile int flags)
|
||||
rv = !execute(t->right, XERROK);
|
||||
break;
|
||||
|
||||
#ifdef KSH
|
||||
case TDBRACKET:
|
||||
{
|
||||
Test_env te;
|
||||
@ -299,14 +285,11 @@ execute(struct op *volatile t, volatile int flags)
|
||||
rv = test_parse(&te);
|
||||
break;
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
case TFOR:
|
||||
#ifdef KSH
|
||||
case TSELECT:
|
||||
{
|
||||
volatile bool_t is_first = TRUE;
|
||||
#endif /* KSH */
|
||||
ap = (t->vars != NULL) ?
|
||||
eval(t->vars, DOBLANK|DOGLOB|DOTILDE)
|
||||
: e->loc->argv + 1;
|
||||
@ -331,9 +314,7 @@ execute(struct op *volatile t, volatile int flags)
|
||||
setstr(global(t->str), *ap++, KSH_UNWIND_ERROR);
|
||||
rv = execute(t->left, flags & XERROK);
|
||||
}
|
||||
}
|
||||
#ifdef KSH
|
||||
else { /* TSELECT */
|
||||
} else { /* TSELECT */
|
||||
for (;;) {
|
||||
if (!(cp = do_selectargs(ap, is_first))) {
|
||||
rv = 1;
|
||||
@ -345,7 +326,6 @@ execute(struct op *volatile t, volatile int flags)
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /* KSH */
|
||||
break;
|
||||
|
||||
case TWHILE:
|
||||
@ -455,7 +435,6 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
|
||||
int fcflags = FC_BI|FC_FUNC|FC_PATH;
|
||||
int bourne_function_call = 0;
|
||||
|
||||
#ifdef KSH
|
||||
/* snag the last argument for $_ XXX not the same as at&t ksh,
|
||||
* which only seems to set $_ after a newline (but not in
|
||||
* functions/dot scripts, but in interactive and script) -
|
||||
@ -468,7 +447,6 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
|
||||
setstr(typeset("_", LOCAL, 0, INTEGER, 0), *--lastp,
|
||||
KSH_RETURN_ERROR);
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
/* Deal with the shell builtins builtin, exec and command since
|
||||
* they can be followed by other commands. This must be done before
|
||||
@ -556,7 +534,7 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
|
||||
if (Flag(FXTRACE)) {
|
||||
if (i == 0)
|
||||
shf_fprintf(shl_out, "%s",
|
||||
PS4_SUBSTITUTE(str_val(global("PS4"))));
|
||||
substitute(str_val(global("PS4")), 0));
|
||||
shf_fprintf(shl_out, "%s%s", cp,
|
||||
t->vars[i + 1] ? space : newline);
|
||||
if (!t->vars[i + 1])
|
||||
@ -711,14 +689,12 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
if (!Flag(FSH)) {
|
||||
/* set $_ to program's full path */
|
||||
/* setstr() can't fail here */
|
||||
setstr(typeset("_", LOCAL|EXPORT, 0, INTEGER, 0),
|
||||
tp->val.s, KSH_RETURN_ERROR);
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
if (flags&XEXEC) {
|
||||
j_exit();
|
||||
@ -1153,7 +1129,7 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
|
||||
if (Flag(FXTRACE))
|
||||
shellf("%s%s\n",
|
||||
PS4_SUBSTITUTE(str_val(global("PS4"))),
|
||||
substitute(str_val(global("PS4")), 0),
|
||||
snptreef((char *) 0, 32, "%R", &iotmp));
|
||||
|
||||
switch (iotype) {
|
||||
@ -1252,7 +1228,6 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
}
|
||||
if (iotype != IODUP)
|
||||
close(u);
|
||||
#ifdef KSH
|
||||
/* Touching any co-process fd in an empty exec
|
||||
* causes the shell to close its copies
|
||||
*/
|
||||
@ -1262,7 +1237,6 @@ iosetup(struct ioword *iop, struct tbl *tp)
|
||||
else /* possible exec >&p */
|
||||
coproc_write_close(u);
|
||||
}
|
||||
#endif /* KSH */
|
||||
}
|
||||
if (u == 2) /* Clear any write errors */
|
||||
shf_reopen(2, SHF_WR, shl_out);
|
||||
@ -1334,7 +1308,6 @@ herein(const char *content, int sub)
|
||||
return fd;
|
||||
}
|
||||
|
||||
#if defined(KSH) || defined(EDIT)
|
||||
/*
|
||||
* ksh special - the select command processing section
|
||||
* print the args in column form - assuming that we can
|
||||
@ -1457,8 +1430,6 @@ pr_list(char *const *ap)
|
||||
|
||||
return n;
|
||||
}
|
||||
#endif /* KSH || EDIT */
|
||||
#ifdef KSH
|
||||
|
||||
/*
|
||||
* [[ ... ]] evaluation routines
|
||||
@ -1543,4 +1514,3 @@ dbteste_error(Test_env *te, int offset, const char *msg)
|
||||
te->flags |= TEF_ERROR;
|
||||
internal_errorf(0, "dbteste_error: %s (offset %d)", msg, offset);
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
9
expr.c
9
expr.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/expr.c,v 2.2 2004/12/13 16:48:53 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/expr.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: expr.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -8,7 +8,7 @@
|
||||
#include "sh.h"
|
||||
#include <ctype.h>
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/expr.c,v 2.2 2004/12/13 16:48:53 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/expr.c,v 2.3 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
/* The order of these enums is constrained by the order of opinfo[] */
|
||||
enum token {
|
||||
@ -466,16 +466,13 @@ token(Expr_state *es)
|
||||
if (len == 0)
|
||||
evalerr(es, ET_STR, "missing ]");
|
||||
cp += len;
|
||||
}
|
||||
#ifdef KSH
|
||||
else if (c == '(' /*)*/ ) {
|
||||
} else if (c == '(' /*)*/ ) {
|
||||
/* todo: add math functions (all take single argument):
|
||||
* abs acos asin atan cos cosh exp int log sin sinh sqrt
|
||||
* tan tanh
|
||||
*/
|
||||
;
|
||||
}
|
||||
#endif /* KSH */
|
||||
if (es->noassign) {
|
||||
es->val = tempvar();
|
||||
es->val->flag |= EXPRLVALUE;
|
||||
|
10
io.c
10
io.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/io.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/io.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -323,17 +323,13 @@ check_fd(char *name, int mode, const char **emsgp)
|
||||
return -1;
|
||||
}
|
||||
return fd;
|
||||
}
|
||||
#ifdef KSH
|
||||
else if (name[0] == 'p' && !name[1])
|
||||
} else if (name[0] == 'p' && !name[1])
|
||||
return coproc_getfd(mode, emsgp);
|
||||
#endif /* KSH */
|
||||
if (emsgp)
|
||||
*emsgp = "illegal file descriptor name";
|
||||
return -1;
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
/* Called once from main */
|
||||
void
|
||||
coproc_init(void)
|
||||
@ -415,8 +411,6 @@ coproc_cleanup(int reuse)
|
||||
coproc.write = -1;
|
||||
}
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
|
||||
/*
|
||||
* temporary files
|
||||
|
14
jobs.c
14
jobs.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/jobs.c,v 2.2 2004/12/13 19:05:09 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/jobs.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: jobs.c,v 1.21 2003/11/10 21:26:39 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -31,7 +31,7 @@
|
||||
#include "ksh_times.h"
|
||||
#include "tty.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 2.2 2004/12/13 19:05:09 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 2.3 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
/* Start of system configuration stuff */
|
||||
|
||||
@ -141,9 +141,7 @@ struct job {
|
||||
clock_t usrtime; /* user time used by job */
|
||||
Proc *proc_list; /* process list */
|
||||
Proc *last_proc; /* last process in list */
|
||||
#ifdef KSH
|
||||
Coproc_id coproc_id; /* 0 or id of coprocess output pipe */
|
||||
#endif /* KSH */
|
||||
#ifdef TTY_PGRP
|
||||
TTY_state ttystate; /* saved tty state for stopped jobs */
|
||||
pid_t saved_ttypgrp; /* saved tty process group for stopped jobs */
|
||||
@ -496,9 +494,7 @@ exchild(struct op *t, int flags, int close_fd)
|
||||
j->ppid = procpid;
|
||||
j->age = ++njobs;
|
||||
j->proc_list = p;
|
||||
#ifdef KSH
|
||||
j->coproc_id = 0;
|
||||
#endif /* KSH */
|
||||
last_job = j;
|
||||
last_proc = p;
|
||||
put_job(j, PJ_PAST_STOPPED);
|
||||
@ -597,11 +593,9 @@ exchild(struct op *t, int flags, int close_fd)
|
||||
|| ((flags & XCCLOSE) && ischild)))
|
||||
close(close_fd);
|
||||
if (ischild) { /* child */
|
||||
#ifdef KSH
|
||||
/* Do this before restoring signal */
|
||||
if (flags & XCOPROC)
|
||||
coproc_cleanup(FALSE);
|
||||
#endif /* KSH */
|
||||
#ifdef JOB_SIGS
|
||||
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
|
||||
#endif /* JOB_SIGS */
|
||||
@ -660,13 +654,11 @@ exchild(struct op *t, int flags, int close_fd)
|
||||
*/
|
||||
#endif /* TTY_PGRP */
|
||||
j_startjob(j);
|
||||
#ifdef KSH
|
||||
if (flags & XCOPROC) {
|
||||
j->coproc_id = coproc.id;
|
||||
coproc.njobs++; /* n jobs using co-process output */
|
||||
coproc.job = (void *) j; /* j using co-process input */
|
||||
}
|
||||
#endif /* KSH */
|
||||
if (flags & XBGND) {
|
||||
j_set_async(j);
|
||||
if (Flag(FTALKING)) {
|
||||
@ -1414,7 +1406,6 @@ check_job(Job *j)
|
||||
break;
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
/* Note when co-process dies: can't be done in j_wait() nor
|
||||
* remove_job() since neither may be called for non-interactive
|
||||
* shells.
|
||||
@ -1437,7 +1428,6 @@ check_job(Job *j)
|
||||
&& --coproc.njobs == 0)
|
||||
coproc_readw_close(coproc.read);
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
j->flags |= JF_CHANGED;
|
||||
#ifdef JOBS
|
||||
|
32
lex.c
32
lex.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/lex.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/lex.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: lex.c,v 1.18 2003/08/06 21:08:05 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -8,7 +8,7 @@
|
||||
#include "sh.h"
|
||||
#include <ctype.h>
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 2.4 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
/* Structure to keep track of the lexing state and the various pieces of info
|
||||
* needed for each particular state.
|
||||
@ -124,14 +124,11 @@ yylex(int cf)
|
||||
|
||||
if (cf&ONEWORD)
|
||||
state = SWORD;
|
||||
#ifdef KSH
|
||||
else if (cf&LETEXPR) {
|
||||
*wp++ = OQUOTE; /* enclose arguments in (double) quotes */
|
||||
state = SLETPAREN;
|
||||
statep->ls_sletparen.nparen = 0;
|
||||
}
|
||||
#endif /* KSH */
|
||||
else { /* normal lexing */
|
||||
} else { /* normal lexing */
|
||||
state = (cf & HEREDELIM) ? SHEREDELIM : SBASE;
|
||||
while ((c = getsc()) == ' ' || c == '\t')
|
||||
;
|
||||
@ -196,7 +193,6 @@ yylex(int cf)
|
||||
}
|
||||
/* fall through.. */
|
||||
Sbase1: /* includes *(...|...) pattern (*+?@!) */
|
||||
#ifdef KSH
|
||||
if (c == '*' || c == '@' || c == '+' || c == '?'
|
||||
|| c == '!')
|
||||
{
|
||||
@ -209,7 +205,6 @@ yylex(int cf)
|
||||
}
|
||||
ungetsc(c2);
|
||||
}
|
||||
#endif /* KSH */
|
||||
/* fall through.. */
|
||||
Sbase2: /* doesn't include *(...|...) pattern (*+?@!) */
|
||||
switch (c) {
|
||||
@ -526,7 +521,6 @@ yylex(int cf)
|
||||
case SWORD: /* ONEWORD */
|
||||
goto Subst;
|
||||
|
||||
#ifdef KSH
|
||||
case SLETPAREN: /* LETEXPR: (( ... )) */
|
||||
/*(*/
|
||||
if (c == ')') {
|
||||
@ -546,7 +540,6 @@ yylex(int cf)
|
||||
*/
|
||||
++statep->ls_sletparen.nparen;
|
||||
goto Sbase2;
|
||||
#endif /* KSH */
|
||||
|
||||
case SHEREDELIM: /* <<,<<- delimiter */
|
||||
/* XXX chuck this state (and the next) - use
|
||||
@ -681,10 +674,8 @@ Done:
|
||||
(c == '|') ? LOGOR :
|
||||
(c == '&') ? LOGAND :
|
||||
YYERRCODE;
|
||||
#ifdef KSH
|
||||
else if (c == '|' && c2 == '&')
|
||||
c = COPROC;
|
||||
#endif /* KSH */
|
||||
else
|
||||
ungetsc(c2);
|
||||
return c;
|
||||
@ -696,7 +687,6 @@ Done:
|
||||
return c;
|
||||
|
||||
case '(': /*)*/
|
||||
#ifdef KSH
|
||||
if (!Flag(FSH)) {
|
||||
if ((c2 = getsc()) == '(') /*)*/
|
||||
/* XXX need to handle ((...); (...)) */
|
||||
@ -704,7 +694,6 @@ Done:
|
||||
else
|
||||
ungetsc(c2);
|
||||
}
|
||||
#endif /* KSH */
|
||||
return c;
|
||||
/*(*/
|
||||
case ')':
|
||||
@ -714,11 +703,8 @@ Done:
|
||||
|
||||
*wp++ = EOS; /* terminate word */
|
||||
yylval.cp = Xclose(ws, wp);
|
||||
if (state == SWORD
|
||||
#ifdef KSH
|
||||
|| state == SLETPAREN
|
||||
#endif /* KSH */
|
||||
) /* ONEWORD? */
|
||||
if (state == SWORD || state == SLETPAREN)
|
||||
/* ONEWORD? */
|
||||
return LWORD;
|
||||
ungetsc(c); /* unget terminator */
|
||||
|
||||
@ -992,12 +978,10 @@ getsc_line(Source *s)
|
||||
*xp = '\0';
|
||||
s->start = s->str = xp;
|
||||
|
||||
#ifdef KSH
|
||||
if (have_tty && ksh_tmout) {
|
||||
ksh_tmout_state = TMOUT_READING;
|
||||
alarm(ksh_tmout);
|
||||
}
|
||||
#endif /* KSH */
|
||||
#ifdef EDIT
|
||||
if (have_tty && (0
|
||||
# ifdef VI
|
||||
@ -1055,13 +1039,11 @@ getsc_line(Source *s)
|
||||
* trap may have been executed.
|
||||
*/
|
||||
source = s;
|
||||
#ifdef KSH
|
||||
if (have_tty && ksh_tmout)
|
||||
{
|
||||
ksh_tmout_state = TMOUT_EXECUTING;
|
||||
alarm(0);
|
||||
}
|
||||
#endif /* KSH */
|
||||
s->start = s->str = Xstring(s->xs, xp);
|
||||
strip_nuls(Xstring(s->xs, xp), Xlength(s->xs, xp));
|
||||
/* Note: if input is all nulls, this is not eof */
|
||||
@ -1099,7 +1081,6 @@ set_prompt(int to, Source *s)
|
||||
|
||||
switch (to) {
|
||||
case PS1: /* command */
|
||||
#ifdef KSH
|
||||
/* Substitute ! and !! here, before substitutions are done
|
||||
* so ! in expanded variables are not expanded.
|
||||
* NOTE: this is not what at&t ksh does (it does it after
|
||||
@ -1136,9 +1117,6 @@ set_prompt(int to, Source *s)
|
||||
saved_atemp);
|
||||
quitenv(NULL);
|
||||
}
|
||||
#else /* KSH */
|
||||
prompt = str_val(global("PS1"));
|
||||
#endif /* KSH */
|
||||
break;
|
||||
|
||||
case PS2: /* command continuation */
|
||||
|
6
lex.h
6
lex.h
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/lex.h,v 2.1 2004/12/10 18:09:41 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/lex.h,v 2.2 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: lex.h,v 1.8 2004/11/02 22:09:24 deraadt Exp $ */
|
||||
/* $From: lex.h,v 1.4 1994/05/31 13:34:34 michael Exp $ */
|
||||
|
||||
@ -55,9 +55,7 @@ struct source {
|
||||
*/
|
||||
#define SBASE 0 /* outside any lexical constructs */
|
||||
#define SWORD 1 /* implicit quoting for substitute() */
|
||||
#ifdef KSH
|
||||
#define SLETPAREN 2 /* inside (( )), implicit quoting */
|
||||
#endif /* KSH */
|
||||
#define SSQUOTE 3 /* inside '' */
|
||||
#define SDQUOTE 4 /* inside "" */
|
||||
#define SBRACE 5 /* inside ${} */
|
||||
@ -99,9 +97,7 @@ typedef union {
|
||||
#define FUNCTION 274
|
||||
#define TIME 275
|
||||
#define REDIR 276
|
||||
#ifdef KSH
|
||||
#define MDPAREN 277 /* (( )) */
|
||||
#endif /* KSH */
|
||||
#define BANG 278 /* ! */
|
||||
#define DBRACKET 279 /* [[ .. ]] */
|
||||
#define COPROC 280 /* |& */
|
||||
|
38
main.c
38
main.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/main.c,v 2.6 2004/12/14 15:54:24 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/main.c,v 2.7 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
|
||||
|
||||
/*
|
||||
@ -15,14 +15,10 @@
|
||||
* shell version
|
||||
*/
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.6 2004/12/14 15:54:24 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.7 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
static const char version_param[] =
|
||||
#ifdef KSH
|
||||
"KSH_VERSION"
|
||||
#else /* KSH */
|
||||
"SH_VERSION"
|
||||
#endif /* KSH */
|
||||
;
|
||||
|
||||
const char ksh_version[] =
|
||||
@ -30,12 +26,7 @@ const char ksh_version[] =
|
||||
#ifdef MIRBSD_NATIVE
|
||||
"native "
|
||||
#endif
|
||||
#ifdef KSH
|
||||
"KSH"
|
||||
#else
|
||||
"POSIX"
|
||||
#endif
|
||||
" mode"
|
||||
"KSH mode"
|
||||
#ifndef MIRBSD_NATIVE
|
||||
" as mksh"
|
||||
#endif
|
||||
@ -64,9 +55,7 @@ static const char *const initcoms [] = {
|
||||
"typeset", "-r", version_param, NULL,
|
||||
"typeset", "-i", "PPID", NULL,
|
||||
"typeset", "-i", "OPTIND=1", NULL,
|
||||
#ifdef KSH
|
||||
"eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
|
||||
#endif /* KSH */
|
||||
"alias",
|
||||
/* Standard ksh aliases */
|
||||
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
|
||||
@ -75,7 +64,6 @@ static const char *const initcoms [] = {
|
||||
"stop=kill -STOP",
|
||||
"suspend=kill -STOP $$",
|
||||
#endif
|
||||
#ifdef KSH
|
||||
"autoload=typeset -fu",
|
||||
"functions=typeset -f",
|
||||
# ifdef HISTORY
|
||||
@ -85,11 +73,8 @@ static const char *const initcoms [] = {
|
||||
"nohup=nohup ",
|
||||
"local=typeset",
|
||||
"r=fc -e -",
|
||||
#endif /* KSH */
|
||||
#ifdef KSH
|
||||
/* Aliases that are builtin commands in at&t */
|
||||
"login=exec login",
|
||||
#endif /* KSH */
|
||||
NULL,
|
||||
/* this is what at&t ksh seems to track, with the addition of emacs */
|
||||
"alias", "-tU",
|
||||
@ -142,11 +127,9 @@ main(int argc, char *argv[])
|
||||
/* Do this first so output routines (eg, errorf, shellf) can work */
|
||||
initio();
|
||||
|
||||
#ifdef KSH
|
||||
argi = parse_args(argv, OF_FIRSTTIME, NULL);
|
||||
if (argi < 0)
|
||||
exit(1);
|
||||
#endif
|
||||
|
||||
initvar();
|
||||
|
||||
@ -154,9 +137,7 @@ main(int argc, char *argv[])
|
||||
|
||||
inittraps();
|
||||
|
||||
#ifdef KSH
|
||||
coproc_init();
|
||||
#endif /* KSH */
|
||||
|
||||
/* set up variable and command dictionaries */
|
||||
tinit(&taliases, APERM, 0);
|
||||
@ -275,11 +256,9 @@ main(int argc, char *argv[])
|
||||
}
|
||||
ppid = getppid();
|
||||
setint(global("PPID"), (long) ppid);
|
||||
#ifdef KSH
|
||||
rnd_seed( (*((long *)kshname))
|
||||
^ ((long) (time(NULL) * kshpid * ppid)) );
|
||||
setint(global("RANDOM"), rnd_get());
|
||||
#endif /* KSH */
|
||||
/* setstr can't fail here */
|
||||
setstr(global(version_param), ksh_version, KSH_RETURN_ERROR);
|
||||
|
||||
@ -393,13 +372,8 @@ main(int argc, char *argv[])
|
||||
else {
|
||||
char *env_file;
|
||||
|
||||
#ifndef KSH
|
||||
if (!Flag(FPOSIX))
|
||||
env_file = null;
|
||||
else
|
||||
#endif /* !KSH */
|
||||
/* include $ENV */
|
||||
env_file = str_val(global("ENV"));
|
||||
/* include $ENV */
|
||||
env_file = str_val(global("ENV"));
|
||||
|
||||
#ifdef DEFAULT_ENV
|
||||
/* If env isn't set, include default environment */
|
||||
@ -428,9 +402,7 @@ main(int argc, char *argv[])
|
||||
|
||||
if (Flag(FTALKING)) {
|
||||
hist_init(s);
|
||||
#ifdef KSH
|
||||
alarm_init();
|
||||
#endif /* KSH */
|
||||
} else
|
||||
Flag(FTRACKALL) = 1; /* set after ENV */
|
||||
|
||||
|
25
misc.c
25
misc.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/misc.c,v 2.3 2004/12/13 19:05:09 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/misc.c,v 2.4 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -13,7 +13,7 @@
|
||||
#include <sys/ioctl.h>
|
||||
#include "ksh_stat.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.3 2004/12/13 19:05:09 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.4 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
#ifndef UCHAR_MAX
|
||||
# define UCHAR_MAX 0xFF
|
||||
@ -25,10 +25,7 @@ static int do_gmatch(const unsigned char *s, const unsigned char *p,
|
||||
const unsigned char *se, const unsigned char *pe,
|
||||
int isfile);
|
||||
static const unsigned char *cclass(const unsigned char *p, int sub);
|
||||
|
||||
#ifdef KSH
|
||||
static int parse_T(char *);
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Fast character classes
|
||||
@ -349,11 +346,7 @@ parse_args(char **argv, int what, int *setargsp)
|
||||
char *p, *q;
|
||||
|
||||
/* see cmd_opts[] declaration */
|
||||
#ifdef KSH
|
||||
strlcpy(cmd_opts, "o:T:", sizeof cmd_opts);
|
||||
#else
|
||||
strlcpy(cmd_opts, "o:", sizeof cmd_opts);
|
||||
#endif
|
||||
p = cmd_opts + strlen(cmd_opts);
|
||||
/* see set_opts[] declaration */
|
||||
strlcpy(set_opts, "A:o;s", sizeof set_opts);
|
||||
@ -388,15 +381,12 @@ parse_args(char **argv, int what, int *setargsp)
|
||||
set = (go.info & GI_PLUS) ? 0 : 1;
|
||||
switch (optc) {
|
||||
case 'A':
|
||||
#ifdef KSH
|
||||
if (what == OF_FIRSTTIME)
|
||||
break;
|
||||
#endif
|
||||
arrayset = set ? 1 : -1;
|
||||
array = go.optarg;
|
||||
break;
|
||||
|
||||
#ifdef KSH
|
||||
case 'T':
|
||||
if (what != OF_FIRSTTIME)
|
||||
break;
|
||||
@ -404,13 +394,10 @@ parse_args(char **argv, int what, int *setargsp)
|
||||
return -1;
|
||||
change_flag(FTALKING, OF_CMDLINE, 1);
|
||||
break;
|
||||
#endif
|
||||
|
||||
case 'o':
|
||||
#ifdef KSH
|
||||
if (what == OF_FIRSTTIME)
|
||||
break;
|
||||
#endif
|
||||
if (go.optarg == (char *) 0) {
|
||||
/* lone -o: print options
|
||||
*
|
||||
@ -441,10 +428,8 @@ parse_args(char **argv, int what, int *setargsp)
|
||||
return -1;
|
||||
|
||||
default:
|
||||
#ifdef KSH
|
||||
if (what == OF_FIRSTTIME)
|
||||
break;
|
||||
#endif
|
||||
/* -s: sort positional params (at&t ksh stupidity) */
|
||||
if (what == OF_SET && optc == 's') {
|
||||
sortargs = 1;
|
||||
@ -675,8 +660,7 @@ do_gmatch(const unsigned char *s, const unsigned char *se, const unsigned char *
|
||||
|
||||
/*
|
||||
* [*+?@!](pattern|pattern|..)
|
||||
*
|
||||
* Not ifdef'd KSH as this is needed for ${..%..}, etc.
|
||||
* ${..%..}, etc.
|
||||
*/
|
||||
case 0x80|'+': /* matches one or more times */
|
||||
case 0x80|'*': /* matches zero or more times */
|
||||
@ -1331,8 +1315,6 @@ ksh_get_wd(char *buf, int bsize)
|
||||
#endif /* HAVE_GETCWD */
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
|
||||
#if !defined(HAVE_SETSID)
|
||||
#define NO_CHVT "setsid not implemented"
|
||||
#elif !defined(TIOCSCTTY)
|
||||
@ -1411,4 +1393,3 @@ parse_T(char *fn)
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/missing.c,v 2.2 2004/12/13 18:53:25 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/missing.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: missing.c,v 1.5 2003/05/16 18:49:46 jsyn Exp $ */
|
||||
|
||||
/*
|
||||
@ -9,7 +9,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include "ksh_dir.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/missing.c,v 2.2 2004/12/13 18:53:25 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/missing.c,v 2.3 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
#ifndef HAVE_MEMSET
|
||||
void *
|
||||
@ -300,8 +300,6 @@ dup2(oldd, newd)
|
||||
#undef HAVE_RANDOM
|
||||
#endif
|
||||
|
||||
#ifdef KSH
|
||||
|
||||
int rnd_state;
|
||||
|
||||
void
|
||||
@ -354,4 +352,3 @@ rnd_put(long newval)
|
||||
}
|
||||
rnd_state = 1;
|
||||
}
|
||||
#endif /* def KSH */
|
||||
|
6
proto.h
6
proto.h
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/proto.h,v 2.3 2004/12/13 18:53:25 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/proto.h,v 2.4 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: proto.h,v 1.11 2003/05/16 19:58:57 jsyn Exp $ */
|
||||
/* $From: proto.h,v 1.3 1994/05/19 18:32:40 michael Exp michael $ */
|
||||
|
||||
@ -132,14 +132,12 @@ void restfd(int fd, int ofd);
|
||||
void openpipe(int *pv);
|
||||
void closepipe(int *pv);
|
||||
int check_fd(char *name, int mode, const char **emsgp);
|
||||
#ifdef KSH
|
||||
void coproc_init(void);
|
||||
void coproc_read_close(int fd);
|
||||
void coproc_readw_close(int fd);
|
||||
void coproc_write_close(int fd);
|
||||
int coproc_getfd(int mode, const char **emsgp);
|
||||
void coproc_cleanup(int reuse);
|
||||
#endif /* KSH */
|
||||
struct temp *maketemp(Area *ap, Temp_type type, struct temp **tlist);
|
||||
/* jobs.c */
|
||||
void j_init(int mflagset);
|
||||
@ -228,9 +226,7 @@ struct tbl ** tsort(struct table *tp);
|
||||
/* trace.c */
|
||||
/* trap.c */
|
||||
void inittraps(void);
|
||||
#ifdef KSH
|
||||
void alarm_init(void);
|
||||
#endif /* KSH */
|
||||
Trap * gettrap(const char *name, int igncase);
|
||||
RETSIGTYPE trapsig(int i);
|
||||
void intrcheck(void);
|
||||
|
6
sh.h
6
sh.h
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/sh.h,v 2.3 2004/12/18 18:39:10 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/sh.h,v 2.4 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: sh.h,v 1.18 2004/05/31 10:36:35 otto Exp $ */
|
||||
|
||||
#ifndef SH_H
|
||||
@ -549,7 +549,6 @@ EXTERN int volatile fatal_trap;/* received a fatal signal */
|
||||
extern Trap sigtraps[SIGNALS+1];
|
||||
#endif /* !FROM_TRAP_C */
|
||||
|
||||
#ifdef KSH
|
||||
/*
|
||||
* TMOUT support
|
||||
*/
|
||||
@ -561,7 +560,6 @@ enum tmout_enum {
|
||||
};
|
||||
EXTERN unsigned int ksh_tmout;
|
||||
EXTERN enum tmout_enum ksh_tmout_state I__(TMOUT_EXECUTING);
|
||||
#endif /* KSH */
|
||||
|
||||
/* For "You have stopped jobs" message */
|
||||
EXTERN int really_exit;
|
||||
@ -613,7 +611,6 @@ typedef struct {
|
||||
EXTERN Getopt builtin_opt; /* for shell builtin commands */
|
||||
EXTERN Getopt user_opt; /* parsing state for getopts builtin command */
|
||||
|
||||
#ifdef KSH
|
||||
/* This for co-processes */
|
||||
|
||||
typedef INT32 Coproc_id; /* something that won't (realisticly) wrap */
|
||||
@ -626,7 +623,6 @@ struct coproc {
|
||||
void *job; /* 0 or job of co-process using input pipe */
|
||||
};
|
||||
EXTERN struct coproc coproc;
|
||||
#endif /* KSH */
|
||||
|
||||
/* Used in jobs.c and by coprocess stuff in exec.c */
|
||||
#ifdef JOB_SIGS
|
||||
|
18
syn.c
18
syn.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/syn.c,v 2.2 2004/12/13 19:09:06 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/syn.c,v 2.3 2004/12/18 18:58:30 tg Exp $ */
|
||||
/* $OpenBSD: syn.c,v 1.14 2003/10/22 07:40:38 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -8,7 +8,7 @@
|
||||
#include "sh.h"
|
||||
#include "c_test.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/syn.c,v 2.2 2004/12/13 19:09:06 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/syn.c,v 2.3 2004/12/18 18:58:30 tg Exp $");
|
||||
|
||||
struct nesting_state {
|
||||
int start_token; /* token than began nesting (eg, FOR) */
|
||||
@ -39,14 +39,12 @@ static void nesting_push(struct nesting_state *save, int tok);
|
||||
static void nesting_pop(struct nesting_state *saved);
|
||||
static int assign_command(char *s);
|
||||
static int inalias(struct source *s);
|
||||
#ifdef KSH
|
||||
static int dbtestp_isa(Test_env *te, Test_meta meta);
|
||||
static const char *dbtestp_getopnd(Test_env *te, Test_op op,
|
||||
int do_eval);
|
||||
static int dbtestp_eval(Test_env *te, Test_op op, const char *opnd1,
|
||||
const char *opnd2, int do_eval);
|
||||
static void dbtestp_error(Test_env *te, int offset, const char *msg);
|
||||
#endif /* KSH */
|
||||
|
||||
static struct op *outtree; /* yyparse output */
|
||||
|
||||
@ -286,7 +284,6 @@ get_command(int cf)
|
||||
t = nested(TBRACE, '{', '}');
|
||||
break;
|
||||
|
||||
#ifdef KSH
|
||||
case MDPAREN:
|
||||
{
|
||||
static const char let_cmd[] = { CHAR, 'l', CHAR, 'e',
|
||||
@ -300,9 +297,7 @@ get_command(int cf)
|
||||
XPput(args, yylval.cp);
|
||||
break;
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
#ifdef KSH
|
||||
case DBRACKET: /* [[ .. ]] */
|
||||
/* Leave KEYWORD in syniocf (allow if [[ -n 1 ]] then ...) */
|
||||
t = newtp(TDBRACKET);
|
||||
@ -320,7 +315,6 @@ get_command(int cf)
|
||||
test_parse(&te);
|
||||
}
|
||||
break;
|
||||
#endif /* KSH */
|
||||
|
||||
case FOR:
|
||||
case SELECT:
|
||||
@ -643,9 +637,7 @@ const struct tokeninfo {
|
||||
{ "case", CASE, TRUE },
|
||||
{ "esac", ESAC, TRUE },
|
||||
{ "for", FOR, TRUE },
|
||||
#ifdef KSH
|
||||
{ "select", SELECT, TRUE },
|
||||
#endif /* KSH */
|
||||
{ "while", WHILE, TRUE },
|
||||
{ "until", UNTIL, TRUE },
|
||||
{ "do", DO, TRUE },
|
||||
@ -656,17 +648,13 @@ const struct tokeninfo {
|
||||
{ "{", '{', TRUE },
|
||||
{ "}", '}', TRUE },
|
||||
{ "!", BANG, TRUE },
|
||||
#ifdef KSH
|
||||
{ "[[", DBRACKET, TRUE },
|
||||
#endif /* KSH */
|
||||
/* Lexical tokens (0[EOF], LWORD and REDIR handled specially) */
|
||||
{ "&&", LOGAND, FALSE },
|
||||
{ "||", LOGOR, FALSE },
|
||||
{ ";;", BREAK, FALSE },
|
||||
#ifdef KSH
|
||||
{ "((", MDPAREN, FALSE },
|
||||
{ "|&", COPROC, FALSE },
|
||||
#endif /* KSH */
|
||||
/* and some special cases... */
|
||||
{ "newline", '\n', FALSE },
|
||||
{ NULL, 0, FALSE }
|
||||
@ -815,7 +803,6 @@ inalias(struct source *s)
|
||||
}
|
||||
|
||||
|
||||
#ifdef KSH
|
||||
/* Order important - indexed by Test_meta values
|
||||
* Note that ||, &&, ( and ) can't appear in as unquoted strings
|
||||
* in normal shell input, so these can be interpreted unambiguously
|
||||
@ -921,4 +908,3 @@ dbtestp_error(Test_env *te, int offset, const char *msg)
|
||||
}
|
||||
syntaxerr(msg);
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
8
trap.c
8
trap.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/trap.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/trap.c,v 2.2 2004/12/18 18:58:31 tg Exp $ */
|
||||
/* $OpenBSD: trap.c,v 1.13 2003/02/28 09:45:09 jmc Exp $ */
|
||||
|
||||
/*
|
||||
@ -9,7 +9,7 @@
|
||||
#define FROM_TRAP_C
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/trap.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/trap.c,v 2.2 2004/12/18 18:58:31 tg Exp $");
|
||||
|
||||
/* Table is indexed by signal number
|
||||
*
|
||||
@ -58,7 +58,6 @@ inittraps(void)
|
||||
setsig(&sigtraps[SIGHUP], trapsig, SS_RESTORE_ORIG);
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
static RETSIGTYPE alarm_catcher(int sig);
|
||||
|
||||
void
|
||||
@ -86,7 +85,6 @@ alarm_catcher(int sig GCC_FUNC_ATTR(unused))
|
||||
errno = errno_;
|
||||
return RETSIGVAL;
|
||||
}
|
||||
#endif /* KSH */
|
||||
|
||||
Trap *
|
||||
gettrap(const char *name, int igncase)
|
||||
@ -200,7 +198,6 @@ runtraps(int flag)
|
||||
int i;
|
||||
Trap *p;
|
||||
|
||||
#ifdef KSH
|
||||
if (ksh_tmout_state == TMOUT_LEAVING) {
|
||||
ksh_tmout_state = TMOUT_EXECUTING;
|
||||
warningf(FALSE, "timed out waiting for input");
|
||||
@ -210,7 +207,6 @@ runtraps(int flag)
|
||||
* is caught after the alarm() was started...not good.
|
||||
*/
|
||||
ksh_tmout_state = TMOUT_EXECUTING;
|
||||
#endif /* KSH */
|
||||
if (!flag)
|
||||
trap = 0;
|
||||
if (flag & TF_DFL_INTR)
|
||||
|
12
tree.c
12
tree.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/tree.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/tree.c,v 2.2 2004/12/18 18:58:32 tg Exp $ */
|
||||
/* $OpenBSD: tree.c,v 1.10 2002/02/27 19:37:09 dhartmei Exp $ */
|
||||
|
||||
/*
|
||||
@ -7,7 +7,7 @@
|
||||
|
||||
#include "sh.h"
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/tree.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/tree.c,v 2.2 2004/12/18 18:58:32 tg Exp $");
|
||||
|
||||
#define INDENT 4
|
||||
|
||||
@ -80,11 +80,9 @@ ptree(struct op *t, int indent, struct shf *shf)
|
||||
fptreef(shf, indent, " ]] ");
|
||||
break;
|
||||
}
|
||||
#ifdef KSH
|
||||
case TSELECT:
|
||||
fptreef(shf, indent, "select %s ", t->str);
|
||||
/* fall through */
|
||||
#endif /* KSH */
|
||||
case TFOR:
|
||||
if (t->type == TFOR)
|
||||
fptreef(shf, indent, "for %s ", t->str);
|
||||
@ -324,7 +322,6 @@ tputS(char *wp, struct shf *shf)
|
||||
if (*wp++ == '}')
|
||||
tputc('}', shf);
|
||||
break;
|
||||
#ifdef KSH
|
||||
case OPAT:
|
||||
tputc(*wp++, shf);
|
||||
tputc('(', shf);
|
||||
@ -335,7 +332,6 @@ tputS(char *wp, struct shf *shf)
|
||||
case CPAT:
|
||||
tputc(')', shf);
|
||||
break;
|
||||
#endif /* KSH */
|
||||
}
|
||||
}
|
||||
|
||||
@ -529,7 +525,6 @@ wdscan(const char *wp, int c)
|
||||
return (char *) wp;
|
||||
nest--;
|
||||
break;
|
||||
#ifdef KSH
|
||||
case OPAT:
|
||||
nest++;
|
||||
wp++;
|
||||
@ -541,7 +536,6 @@ wdscan(const char *wp, int c)
|
||||
if (wp[-1] == CPAT)
|
||||
nest--;
|
||||
break;
|
||||
#endif /* KSH */
|
||||
default:
|
||||
internal_errorf(0,
|
||||
"wdscan: unknown char 0x%x (carrying on)",
|
||||
@ -605,7 +599,6 @@ wdstrip(const char *wp)
|
||||
if (*wp++ == '}')
|
||||
shf_putchar('}', &shf);
|
||||
break;
|
||||
#ifdef KSH
|
||||
case OPAT:
|
||||
shf_putchar(*wp++, &shf);
|
||||
shf_putchar('(', &shf);
|
||||
@ -616,7 +609,6 @@ wdstrip(const char *wp)
|
||||
case CPAT:
|
||||
shf_putchar(')', &shf);
|
||||
break;
|
||||
#endif /* KSH */
|
||||
}
|
||||
}
|
||||
|
||||
|
14
var.c
14
var.c
@ -1,4 +1,4 @@
|
||||
/** $MirBSD: src/bin/ksh/var.c,v 2.2 2004/12/18 18:39:10 tg Exp $ */
|
||||
/** $MirBSD: src/bin/ksh/var.c,v 2.3 2004/12/18 18:58:32 tg Exp $ */
|
||||
/* $OpenBSD: var.c,v 1.17 2004/05/08 19:42:35 deraadt Exp $ */
|
||||
|
||||
#include "sh.h"
|
||||
@ -7,7 +7,7 @@
|
||||
#include "ksh_stat.h"
|
||||
#include <ctype.h>
|
||||
|
||||
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.2 2004/12/18 18:39:10 tg Exp $");
|
||||
__RCSID("$MirBSD: src/bin/ksh/var.c,v 2.3 2004/12/18 18:58:32 tg Exp $");
|
||||
|
||||
/*
|
||||
* Variables
|
||||
@ -102,11 +102,9 @@ initvar(void)
|
||||
{ "EDITOR", V_EDITOR },
|
||||
{ "VISUAL", V_VISUAL },
|
||||
#endif /* EDIT */
|
||||
#ifdef KSH
|
||||
{ "RANDOM", V_RANDOM },
|
||||
{ "SECONDS", V_SECONDS },
|
||||
{ "TMOUT", V_TMOUT },
|
||||
#endif /* KSH */
|
||||
{ "LINENO", V_LINENO },
|
||||
{ (char *) 0, 0 }
|
||||
};
|
||||
@ -886,16 +884,13 @@ unspecial(const char *name)
|
||||
tdelete(tp);
|
||||
}
|
||||
|
||||
#ifdef KSH
|
||||
static time_t seconds; /* time SECONDS last set */
|
||||
#endif /* KSH */
|
||||
static int user_lineno; /* what user set $LINENO to */
|
||||
|
||||
static void
|
||||
getspec(struct tbl *vp)
|
||||
{
|
||||
switch (special(vp->name)) {
|
||||
#ifdef KSH
|
||||
case V_SECONDS:
|
||||
vp->flag &= ~SPECIAL;
|
||||
/* On start up the value of SECONDS is used before seconds
|
||||
@ -911,7 +906,6 @@ getspec(struct tbl *vp)
|
||||
setint(vp, rnd_get());
|
||||
vp->flag |= SPECIAL;
|
||||
break;
|
||||
#endif /* KSH */
|
||||
#ifdef HISTORY
|
||||
case V_HISTSIZE:
|
||||
vp->flag &= ~SPECIAL;
|
||||
@ -995,7 +989,6 @@ setspec(struct tbl *vp)
|
||||
x_cols = MIN_COLS;
|
||||
break;
|
||||
#endif /* EDIT */
|
||||
#ifdef KSH
|
||||
case V_RANDOM:
|
||||
vp->flag &= ~SPECIAL;
|
||||
rnd_put(intval(vp));
|
||||
@ -1011,7 +1004,6 @@ setspec(struct tbl *vp)
|
||||
if (vp->flag & INTEGER)
|
||||
ksh_tmout = vp->val.i >= 0 ? vp->val.i : 0;
|
||||
break;
|
||||
#endif /* KSH */
|
||||
case V_LINENO:
|
||||
vp->flag &= ~SPECIAL;
|
||||
/* The -1 is because line numbering starts at 1. */
|
||||
@ -1043,11 +1035,9 @@ unsetspec(struct tbl *vp)
|
||||
}
|
||||
break;
|
||||
case V_LINENO:
|
||||
#ifdef KSH
|
||||
case V_RANDOM:
|
||||
case V_SECONDS:
|
||||
case V_TMOUT: /* at&t ksh leaves previous value in place */
|
||||
#endif /* KSH */
|
||||
unspecial(vp->name);
|
||||
break;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user