summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>2004-12-18 21:04:53 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>2004-12-18 21:04:53 +0000
commitb228348292c4361c750ae05a5597a15e71c5c5da (patch)
treee7527881cd44cefdbbcd11ec8332b581e2e4f8ec
parent55e483bc0655baec919e26c2dfcdda314a467a32 (diff)
Get rid of #ifdef KSH since we don't care about building a V7 style sh and
the #ifdef KSH code is required to make a POSIX sh. From Matthias Kilian
-rw-r--r--bin/ksh/Makefile4
-rw-r--r--bin/ksh/c_ksh.c18
-rw-r--r--bin/ksh/c_sh.c10
-rw-r--r--bin/ksh/c_test.c4
-rw-r--r--bin/ksh/config.h5
-rw-r--r--bin/ksh/exec.c33
-rw-r--r--bin/ksh/expr.c7
-rw-r--r--bin/ksh/io.c9
-rw-r--r--bin/ksh/jobs.c12
-rw-r--r--bin/ksh/lex.c83
-rw-r--r--bin/ksh/lex.h6
-rw-r--r--bin/ksh/mail.c4
-rw-r--r--bin/ksh/main.c31
-rw-r--r--bin/ksh/proto.h8
-rw-r--r--bin/ksh/sh.h6
-rw-r--r--bin/ksh/syn.c16
-rw-r--r--bin/ksh/trap.c6
-rw-r--r--bin/ksh/tree.c10
-rw-r--r--bin/ksh/var.c15
19 files changed, 55 insertions, 232 deletions
diff --git a/bin/ksh/Makefile b/bin/ksh/Makefile
index 7faaf9c467d..61b2441ef62 100644
--- a/bin/ksh/Makefile
+++ b/bin/ksh/Makefile
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile,v 1.19 2004/12/18 20:55:52 millert Exp $
+# $OpenBSD: Makefile,v 1.20 2004/12/18 21:04:52 millert Exp $
PROG= ksh
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c \
@@ -7,7 +7,7 @@ SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c \
tree.c tty.c var.c version.c vi.c
DEFS= -Wall -Wno-unused
-CFLAGS+=${DEFS} -I. -I${.CURDIR} -DKSH
+CFLAGS+=${DEFS} -I. -I${.CURDIR}
MAN= ksh.1 sh.1
CLEANFILES+= siglist.out emacs.out
diff --git a/bin/ksh/c_ksh.c b/bin/ksh/c_ksh.c
index f1071f0afe6..ec21c799593 100644
--- a/bin/ksh/c_ksh.c
+++ b/bin/ksh/c_ksh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_ksh.c,v 1.19 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: c_ksh.c,v 1.20 2004/12/18 21:04:52 millert Exp $ */
/*
* built-in Korn commands: c_*
@@ -258,14 +258,12 @@ c_print(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;
@@ -352,7 +350,6 @@ c_print(wp)
} else {
int n, len = Xlength(xs, xp);
int opipe = 0;
-#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
@@ -363,40 +360,31 @@ c_print(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;
@@ -1023,7 +1011,6 @@ c_unalias(wp)
return rv;
}
-#ifdef KSH
int
c_let(wp)
char **wp;
@@ -1042,7 +1029,6 @@ c_let(wp)
rv = val == 0;
return rv;
}
-#endif /* KSH */
int
c_jobs(wp)
@@ -1414,9 +1400,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},
diff --git a/bin/ksh/c_sh.c b/bin/ksh/c_sh.c
index a2c5fb14d6d..7bd9d0adfb4 100644
--- a/bin/ksh/c_sh.c
+++ b/bin/ksh/c_sh.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_sh.c,v 1.18 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: c_sh.c,v 1.19 2004/12/18 21:04:52 millert Exp $ */
/*
* built-in Bourne commands
@@ -252,14 +252,12 @@ c_read(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;
@@ -299,7 +297,6 @@ c_read(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.
@@ -310,7 +307,6 @@ c_read(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);
@@ -403,14 +399,12 @@ c_read(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;
}
@@ -840,10 +834,8 @@ c_exec(wp)
* 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;
}
diff --git a/bin/ksh/c_test.c b/bin/ksh/c_test.c
index e95652f68f4..ce859d0b21d 100644
--- a/bin/ksh/c_test.c
+++ b/bin/ksh/c_test.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: c_test.c,v 1.11 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: c_test.c,v 1.12 2004/12/18 21:04:52 millert Exp $ */
/*
* test(1); version 7-like -- author Erik Baalbergen
@@ -69,9 +69,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 },
diff --git a/bin/ksh/config.h b/bin/ksh/config.h
index 7c6d96ece92..3cd16b86e23 100644
--- a/bin/ksh/config.h
+++ b/bin/ksh/config.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: config.h,v 1.11 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: config.h,v 1.12 2004/12/18 21:04:52 millert Exp $ */
/* config.h. NOT generated automatically. */
@@ -18,9 +18,6 @@
#define HAVE_GCC_FUNC_ATTR 1
-/* Include ksh features? */
-/* #define KSH 1 */
-
/* Include emacs editing? */
#define EMACS 1
diff --git a/bin/ksh/exec.c b/bin/ksh/exec.c
index a210a960f9d..4b1dcafd3c3 100644
--- a/bin/ksh/exec.c
+++ b/bin/ksh/exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: exec.c,v 1.32 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: exec.c,v 1.33 2004/12/18 21:04:52 millert Exp $ */
/*
* execute command tree
@@ -10,11 +10,7 @@
#include <sys/stat.h>
/* Does ps4 get parameter substitutions done? */
-#ifdef KSH
# define PS4_SUBSTITUTE(s) substitute((s), 0)
-#else
-# define PS4_SUBSTITUTE(s) (s)
-#endif /* KSH */
static int comexec(struct op *t, struct tbl *volatile tp, char **ap,
int volatile flags);
@@ -22,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 */
/*
@@ -175,7 +167,6 @@ execute(t, flags)
rv = execute(t, flags & XERROK);
break;
-#ifdef KSH
case TCOPROC:
{
sigset_t omask;
@@ -234,7 +225,6 @@ execute(t, flags)
coproc.readw);
break;
}
-#endif /* KSH */
case TASYNC:
/* XXX non-optimal, I think - "(foo &)", forks for (),
@@ -257,7 +247,6 @@ execute(t, flags)
rv = !execute(t->right, XERROK);
break;
-#ifdef KSH
case TDBRACKET:
{
Test_env te;
@@ -272,14 +261,11 @@ execute(t, 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;
@@ -304,9 +290,7 @@ execute(t, 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;
@@ -318,7 +302,6 @@ execute(t, flags)
}
}
}
-#endif /* KSH */
break;
case TWHILE:
@@ -425,7 +408,6 @@ comexec(t, tp, ap, 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) -
@@ -438,7 +420,6 @@ comexec(t, tp, ap, 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
@@ -681,14 +662,12 @@ comexec(t, tp, ap, 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();
@@ -1192,7 +1171,6 @@ iosetup(iop, tp)
}
if (iotype != IODUP)
close(u);
-#ifdef KSH
/* Touching any co-process fd in an empty exec
* causes the shell to close its copies
*/
@@ -1202,7 +1180,6 @@ iosetup(iop, 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);
@@ -1277,7 +1254,7 @@ herein(content, sub)
return fd;
}
-#if defined(KSH) || defined(EDIT)
+#ifdef EDIT
/*
* ksh special - the select command processing section
* print the args in column form - assuming that we can
@@ -1412,8 +1389,7 @@ pr_list(ap)
return n;
}
-#endif /* KSH || EDIT */
-#ifdef KSH
+#endif /* EDIT */
/*
* [[ ... ]] evaluation routines
@@ -1511,4 +1487,3 @@ dbteste_error(te, offset, msg)
te->flags |= TEF_ERROR;
internal_errorf(0, "dbteste_error: %s (offset %d)", msg, offset);
}
-#endif /* KSH */
diff --git a/bin/ksh/expr.c b/bin/ksh/expr.c
index e04abfd24d0..90f163d2952 100644
--- a/bin/ksh/expr.c
+++ b/bin/ksh/expr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: expr.c,v 1.10 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: expr.c,v 1.11 2004/12/18 21:04:52 millert Exp $ */
/*
* Korn expression evaluation
@@ -481,16 +481,13 @@ token(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;
diff --git a/bin/ksh/io.c b/bin/ksh/io.c
index 1ab2882e216..9a2a00db5f8 100644
--- a/bin/ksh/io.c
+++ b/bin/ksh/io.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: io.c,v 1.14 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: io.c,v 1.15 2004/12/18 21:04:52 millert Exp $ */
/*
* shell buffered IO and formatted output
@@ -329,17 +329,13 @@ check_fd(name, mode, 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()
@@ -427,7 +423,6 @@ coproc_cleanup(reuse)
coproc.write = -1;
}
}
-#endif /* KSH */
/*
diff --git a/bin/ksh/jobs.c b/bin/ksh/jobs.c
index e83f32ed08a..ee76a1c0adc 100644
--- a/bin/ksh/jobs.c
+++ b/bin/ksh/jobs.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: jobs.c,v 1.23 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: jobs.c,v 1.24 2004/12/18 21:04:52 millert Exp $ */
/*
* Process and job control
@@ -75,9 +75,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 JOBS
TTY_state ttystate; /* saved tty state for stopped jobs */
pid_t saved_ttypgrp; /* saved tty process group for stopped jobs */
@@ -375,9 +373,7 @@ exchild(t, flags, 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);
@@ -433,11 +429,9 @@ exchild(t, flags, 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 */
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
cleanup_parents_env();
#ifdef JOBS
@@ -492,13 +486,11 @@ exchild(t, flags, close_fd)
*/
#endif /* JOBS */
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)) {
@@ -1207,7 +1199,6 @@ check_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.
@@ -1230,7 +1221,6 @@ check_job(j)
&& --coproc.njobs == 0)
coproc_readw_close(coproc.read);
}
-#endif /* KSH */
j->flags |= JF_CHANGED;
#ifdef JOBS
diff --git a/bin/ksh/lex.c b/bin/ksh/lex.c
index 40e7821c66f..d104795c302 100644
--- a/bin/ksh/lex.c
+++ b/bin/ksh/lex.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.c,v 1.24 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: lex.c,v 1.25 2004/12/18 21:04:52 millert Exp $ */
/*
* lexical analysis and source input
@@ -124,14 +124,11 @@ yylex(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')
;
@@ -256,7 +253,6 @@ yylex(cf)
}
/* fall through.. */
Sbase1: /* includes *(...|...) pattern (*+?@!) */
-#ifdef KSH
if (c == '*' || c == '@' || c == '+' || c == '?'
|| c == '!')
{
@@ -269,7 +265,6 @@ yylex(cf)
}
ungetsc(c2);
}
-#endif /* KSH */
/* fall through.. */
Sbase2: /* doesn't include *(...|...) pattern (*+?@!) */
switch (c) {
@@ -586,7 +581,6 @@ yylex(cf)
case SWORD: /* ONEWORD */
goto Subst;
-#ifdef KSH
case SLETPAREN: /* LETEXPR: (( ... )) */
/*(*/
if (c == ')') {
@@ -606,7 +600,6 @@ yylex(cf)
*/
++statep->ls_sletparen.nparen;
goto Sbase2;
-#endif /* KSH */
case SHEREDELIM: /* <<,<<- delimiter */
/* XXX chuck this state (and the next) - use
@@ -741,10 +734,8 @@ Done:
(c == '|') ? LOGOR :
(c == '&') ? LOGAND :
YYERRCODE;
-#ifdef KSH
else if (c == '|' && c2 == '&')
c = COPROC;
-#endif /* KSH */
else
ungetsc(c2);
return c;
@@ -756,7 +747,6 @@ Done:
return c;
case '(': /*)*/
-#ifdef KSH
if (!Flag(FSH)) {
if ((c2 = getsc()) == '(') /*)*/
/* XXX need to handle ((...); (...)) */
@@ -764,7 +754,6 @@ Done:
else
ungetsc(c2);
}
-#endif /* KSH */
return c;
/*(*/
case ')':
@@ -774,11 +763,7 @@ 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 */
@@ -1056,12 +1041,10 @@ getsc_line(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
@@ -1119,13 +1102,10 @@ getsc_line(s)
* trap may have been executed.
*/
source = s;
-#ifdef KSH
- if (have_tty && ksh_tmout)
- {
+ 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 */
@@ -1154,42 +1134,35 @@ set_prompt(to, s)
int to;
Source *s;
{
+ struct shf *shf;
+ char * volatile ps1;
+ Area *saved_atemp;
+
cur_prompt = to;
switch (to) {
case PS1: /* command */
-#ifdef KSH
- {
- struct shf *shf;
- char * volatile ps1;
- Area *saved_atemp;
-
- ps1 = str_val(global("PS1"));
- shf = shf_sopen((char *) 0, strlen(ps1) * 2,
- SHF_WR | SHF_DYNAMIC, (struct shf *) 0);
- while (*ps1)
- shf_putchar(*ps1++, shf);
- ps1 = shf_sclose(shf);
- saved_atemp = ATEMP;
- newenv(E_ERRH);
- if (sigsetjmp(e->jbuf, 0)) {
- prompt = safe_prompt;
- /* Don't print an error - assume it has already
- * been printed. Reason is we may have forked
- * to run a command and the child may be
- * unwinding its stack through this code as it
- * exits.
- */
- } else
- prompt = str_save(substitute(ps1, 0),
- saved_atemp);
- quitenv();
- }
-#else /* KSH */
- prompt = str_val(global("PS1"));
-#endif /* KSH */
+ ps1 = str_val(global("PS1"));
+ shf = shf_sopen((char *) 0, strlen(ps1) * 2,
+ SHF_WR | SHF_DYNAMIC, (struct shf *) 0);
+ while (*ps1)
+ shf_putchar(*ps1++, shf);
+ ps1 = shf_sclose(shf);
+ saved_atemp = ATEMP;
+ newenv(E_ERRH);
+ if (sigsetjmp(e->jbuf, 0)) {
+ prompt = safe_prompt;
+ /* Don't print an error - assume it has already
+ * been printed. Reason is we may have forked
+ * to run a command and the child may be
+ * unwinding its stack through this code as it
+ * exits.
+ */
+ } else
+ prompt = str_save(substitute(ps1, 0),
+ saved_atemp);
+ quitenv();
break;
-
case PS2: /* command continuation */
prompt = str_val(global("PS2"));
break;
diff --git a/bin/ksh/lex.h b/bin/ksh/lex.h
index 016f8b2cd36..ce66470b2c2 100644
--- a/bin/ksh/lex.h
+++ b/bin/ksh/lex.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: lex.h,v 1.8 2004/11/02 22:09:24 deraadt Exp $ */
+/* $OpenBSD: lex.h,v 1.9 2004/12/18 21:04:52 millert Exp $ */
/*
* Source input, lexer and parser
@@ -52,9 +52,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 ${} */
@@ -96,9 +94,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 /* |& */
diff --git a/bin/ksh/mail.c b/bin/ksh/mail.c
index 3429935ff02..66f2836abf7 100644
--- a/bin/ksh/mail.c
+++ b/bin/ksh/mail.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: mail.c,v 1.10 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: mail.c,v 1.11 2004/12/18 21:04:52 millert Exp $ */
/*
* Mailbox checking code by Robert J. Gibson, adapted for PD ksh by
@@ -7,7 +7,6 @@
#include "config.h"
-#ifdef KSH
#include "sh.h"
#include <sys/stat.h>
#include <time.h>
@@ -202,4 +201,3 @@ mbox_t *mbp;
unset(vp, 0);
}
-#endif /* KSH */
diff --git a/bin/ksh/main.c b/bin/ksh/main.c
index 361d40478c7..39443f537ff 100644
--- a/bin/ksh/main.c
+++ b/bin/ksh/main.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: main.c,v 1.29 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: main.c,v 1.30 2004/12/18 21:04:52 millert Exp $ */
/*
* startup, main loop, environments and error handling
@@ -27,22 +27,14 @@ static const char initifs[] = "IFS= \t\n";
static const char initsubs[] = "${PS2=> } ${PS3=#? } ${PS4=+ }";
-static const char version_param[] =
-#ifdef KSH
- "KSH_VERSION"
-#else /* KSH */
- "SH_VERSION"
-#endif /* KSH */
- ;
+static const char version_param[] = "KSH_VERSION";
static const char *const initcoms [] = {
"typeset", "-x", "SHELL", "PATH", "HOME", NULL,
"typeset", "-r", version_param, NULL,
"typeset", "-i", "PPID", NULL,
"typeset", "-i", "OPTIND=1", NULL,
-#ifdef KSH
"eval", "typeset -i RANDOM MAILCHECK=\"${MAILCHECK-600}\" SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
-#endif /* KSH */
"alias",
/* Standard ksh aliases */
"hash=alias -t", /* not "alias -t --": hash -r needs to work */
@@ -51,21 +43,17 @@ static const char *const initcoms [] = {
"stop=kill -STOP",
"suspend=kill -STOP $$",
#endif
-#ifdef KSH
"autoload=typeset -fu",
"functions=typeset -f",
-# ifdef HISTORY
+#ifdef HISTORY
"history=fc -l",
-# endif /* HISTORY */
+#endif /* HISTORY */
"integer=typeset -i",
"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",
@@ -116,9 +104,7 @@ main(int argc, char *argv[])
inittraps();
-#ifdef KSH
coproc_init();
-#endif /* KSH */
/* set up variable and command dictionaries */
tinit(&taliases, APERM, 0);
@@ -348,11 +334,6 @@ 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"));
@@ -383,9 +364,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 */
@@ -548,9 +527,7 @@ shell(s, toplevel)
if (interactive) {
j_notify();
-#ifdef KSH
mcheck();
-#endif /* KSH */
set_prompt(PS1, s);
}
diff --git a/bin/ksh/proto.h b/bin/ksh/proto.h
index 712bb685a35..2f64e172b79 100644
--- a/bin/ksh/proto.h
+++ b/bin/ksh/proto.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: proto.h,v 1.14 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: proto.h,v 1.15 2004/12/18 21:04:52 millert Exp $ */
/*
* prototypes for PD-KSH
@@ -125,14 +125,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);
@@ -157,12 +155,10 @@ Source * pushs(int type, Area *areap);
void set_prompt(int to, Source *s);
void pprompt(const char *cp, int ntruncate);
/* mail.c */
-#ifdef KSH
void mcheck(void);
void mcset(long interval);
void mbset(char *p);
void mpset(char *mptoparse);
-#endif /* KSH */
/* main.c */
int include(const char *name, int argc, char **argv, int intr_ok);
int command(const char *comm);
@@ -224,9 +220,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);
void trapsig(int i);
void intrcheck(void);
diff --git a/bin/ksh/sh.h b/bin/ksh/sh.h
index 920bdbdff20..a552f721745 100644
--- a/bin/ksh/sh.h
+++ b/bin/ksh/sh.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: sh.h,v 1.20 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: sh.h,v 1.21 2004/12/18 21:04:52 millert Exp $ */
/*
* Public Domain Bourne/Korn shell
@@ -299,7 +299,6 @@ EXTERN int volatile intrsig; /* pending trap interrupts executing command */
EXTERN int volatile fatal_trap;/* received a fatal signal */
extern Trap sigtraps[NSIG+1];
-#ifdef KSH
/*
* TMOUT support
*/
@@ -311,7 +310,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;
@@ -363,7 +361,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 */
@@ -376,7 +373,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 */
EXTERN sigset_t sm_default, sm_sigchld;
diff --git a/bin/ksh/syn.c b/bin/ksh/syn.c
index 607484ecdff..1896d5611dd 100644
--- a/bin/ksh/syn.c
+++ b/bin/ksh/syn.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: syn.c,v 1.15 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: syn.c,v 1.16 2004/12/18 21:04:52 millert Exp $ */
/*
* shell parser (C version)
@@ -36,13 +36,11 @@ 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 */
@@ -288,7 +286,6 @@ get_command(cf)
t = nested(TBRACE, '{', '}');
break;
-#ifdef KSH
case MDPAREN:
{
static const char let_cmd[] = { CHAR, 'l', CHAR, 'e',
@@ -302,9 +299,7 @@ get_command(cf)
XPput(args, yylval.cp);
break;
}
-#endif /* KSH */
-#ifdef KSH
case DBRACKET: /* [[ .. ]] */
/* Leave KEYWORD in syniocf (allow if [[ -n 1 ]] then ...) */
t = newtp(TDBRACKET);
@@ -322,7 +317,6 @@ get_command(cf)
test_parse(&te);
}
break;
-#endif /* KSH */
case FOR:
case SELECT:
@@ -649,9 +643,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 },
@@ -662,17 +654,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 },
{ 0 }
@@ -829,7 +817,6 @@ inalias(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
@@ -943,4 +930,3 @@ dbtestp_error(te, offset, msg)
}
syntaxerr(msg);
}
-#endif /* KSH */
diff --git a/bin/ksh/trap.c b/bin/ksh/trap.c
index 25244ac2c5b..94bc6179e9a 100644
--- a/bin/ksh/trap.c
+++ b/bin/ksh/trap.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: trap.c,v 1.14 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: trap.c,v 1.15 2004/12/18 21:04:52 millert Exp $ */
/*
* signal handling
@@ -48,7 +48,6 @@ inittraps()
setsig(&sigtraps[SIGHUP], trapsig, SS_RESTORE_ORIG);
}
-#ifdef KSH
static void alarm_catcher(int sig);
void
@@ -76,7 +75,6 @@ alarm_catcher(sig)
}
errno = errno_;
}
-#endif /* KSH */
Trap *
gettrap(name, igncase)
@@ -189,7 +187,6 @@ runtraps(flag)
int i;
register Trap *p;
-#ifdef KSH
if (ksh_tmout_state == TMOUT_LEAVING) {
ksh_tmout_state = TMOUT_EXECUTING;
warningf(FALSE, "timed out waiting for input");
@@ -199,7 +196,6 @@ runtraps(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)
diff --git a/bin/ksh/tree.c b/bin/ksh/tree.c
index 99f8ef386c1..c4ca9067782 100644
--- a/bin/ksh/tree.c
+++ b/bin/ksh/tree.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: tree.c,v 1.11 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: tree.c,v 1.12 2004/12/18 21:04:52 millert Exp $ */
/*
* command tree climbing
@@ -97,11 +97,9 @@ ptree(t, indent, 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);
@@ -348,7 +346,6 @@ tputS(wp, shf)
if (*wp++ == '}')
tputc('}', shf);
break;
-#ifdef KSH
case OPAT:
tputc(*wp++, shf);
tputc('(', shf);
@@ -359,7 +356,6 @@ tputS(wp, shf)
case CPAT:
tputc(')', shf);
break;
-#endif /* KSH */
}
}
@@ -563,7 +559,6 @@ wdscan(wp, c)
return (char *) wp;
nest--;
break;
-#ifdef KSH
case OPAT:
nest++;
wp++;
@@ -575,7 +570,6 @@ wdscan(wp, c)
if (wp[-1] == CPAT)
nest--;
break;
-#endif /* KSH */
default:
internal_errorf(0,
"wdscan: unknown char 0x%x (carrying on)",
@@ -640,7 +634,6 @@ wdstrip(wp)
if (*wp++ == '}')
shf_putchar('}', &shf);
break;
-#ifdef KSH
case OPAT:
shf_putchar(*wp++, &shf);
shf_putchar('(', &shf);
@@ -651,7 +644,6 @@ wdstrip(wp)
case CPAT:
shf_putchar(')', &shf);
break;
-#endif /* KSH */
}
}
diff --git a/bin/ksh/var.c b/bin/ksh/var.c
index 688d9630b70..ffacb192e50 100644
--- a/bin/ksh/var.c
+++ b/bin/ksh/var.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: var.c,v 1.18 2004/12/18 20:55:52 millert Exp $ */
+/* $OpenBSD: var.c,v 1.19 2004/12/18 21:04:52 millert Exp $ */
#include "sh.h"
#include <time.h>
@@ -99,14 +99,12 @@ initvar()
{ "EDITOR", V_EDITOR },
{ "VISUAL", V_VISUAL },
#endif /* EDIT */
-#ifdef KSH
{ "MAIL", V_MAIL },
{ "MAILCHECK", V_MAILCHECK },
{ "MAILPATH", V_MAILPATH },
{ "RANDOM", V_RANDOM },
{ "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT },
-#endif /* KSH */
{ "LINENO", V_LINENO },
{ (char *) 0, 0 }
};
@@ -927,9 +925,7 @@ unspecial(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
@@ -937,7 +933,6 @@ getspec(vp)
register 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
@@ -956,7 +951,6 @@ getspec(vp)
setint(vp, (long) (arc4random() & 0x7fff));
vp->flag |= SPECIAL;
break;
-#endif /* KSH */
#ifdef HISTORY
case V_HISTSIZE:
vp->flag &= ~SPECIAL;
@@ -1041,7 +1035,6 @@ setspec(vp)
x_cols = MIN_COLS;
break;
#endif /* EDIT */
-#ifdef KSH
case V_MAIL:
mbset(str_val(vp));
break;
@@ -1069,7 +1062,6 @@ setspec(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. */
@@ -1101,22 +1093,17 @@ unsetspec(vp)
tmpdir = (char *) 0;
}
break;
-#ifdef KSH
case V_MAIL:
mbset((char *) 0);
break;
case V_MAILPATH:
mpset((char *) 0);
break;
-#endif /* KSH */
-
case V_LINENO:
-#ifdef KSH
case V_MAILCHECK: /* at&t ksh leaves previous value in place */
case V_RANDOM:
case V_SECONDS:
case V_TMOUT: /* at&t ksh leaves previous value in place */
-#endif /* KSH */
unspecial(vp->name);
break;