Initial revision

This commit is contained in:
tg 2004-12-10 18:12:29 +00:00
parent 8a1afa6087
commit 7920708324
68 changed files with 248 additions and 121 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirBSD: Build.sh,v 1.18 2004/12/10 15:32:58 tg Exp $
# $MirBSD: src/bin/ksh/Build.sh,v 1.1 2004/12/10 18:08:08 tg Exp $
#-
# Copyright (c) 2004
# Thorsten "mirabile" Glaser <tg@66h.42h.de>

View File

@ -1,4 +1,4 @@
$MirBSD: CONTRIBUTORS,v 1.4 2004/06/02 15:06:49 tg Stab $
$MirBSD: src/bin/ksh/CONTRIBUTORS,v 1.1 2004/12/10 18:08:08 tg Exp $
$OpenBSD: CONTRIBUTORS,v 1.9 1999/07/14 13:37:23 millert Exp $
This is a partial history of this shell gleened from old change logs and

View File

@ -1,4 +1,4 @@
# $MirBSD: Makefile,v 1.10 2004/11/10 17:13:10 tg Exp $
# $MirBSD: src/bin/ksh/Makefile,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: Makefile,v 1.18 2004/02/16 19:07:19 deraadt Exp $
PROG= ksh

2
NOTES
View File

@ -1,4 +1,4 @@
$MirBSD: NOTES,v 1.3 2004/11/10 17:13:10 tg Exp $
$MirBSD: src/bin/ksh/NOTES,v 1.1 2004/12/10 18:08:08 tg Exp $
$OpenBSD: NOTES,v 1.9 2003/10/26 15:07:25 jmc Exp $
General features of at&t ksh88 that are not (yet) in pdksh:

View File

@ -1,4 +1,4 @@
$MirBSD: PROJECTS,v 1.5 2004/11/10 17:13:10 tg Exp $
$MirBSD: src/bin/ksh/PROJECTS,v 1.1 2004/12/10 18:08:08 tg Exp $
$OpenBSD: PROJECTS,v 1.5 1999/07/14 13:37:23 millert Exp $

2
README
View File

@ -1,4 +1,4 @@
$MirBSD: README,v 1.5 2004/11/10 17:22:12 tg Exp $
$MirBSD: src/bin/ksh/README,v 1.1 2004/12/10 18:08:08 tg Exp $
This is the README for mirbsdksh, developed as part of the MirBSD
operating system at The MirOS Project, and produced portably.

2
aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
dnl $MirBSD: aclocal.m4,v 1.12 2004/12/10 15:22:19 tg Exp $
dnl $MirBSD: src/bin/ksh/aclocal.m4,v 1.1 2004/12/10 18:08:08 tg Exp $
dnl-
dnl Copyright (c) 2004
dnl Thorsten "mirabile" Glaser <tg@66h.42h.de>

View File

@ -1,4 +1,4 @@
/** $MirBSD: alloc.c,v 1.6 2004/11/01 12:30:09 tg Exp $ */
/** $MirBSD: src/bin/ksh/alloc.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: alloc.c,v 1.7 2004/02/19 18:51:17 deraadt Exp $ */
/*

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_ksh.c,v 1.9 2004/10/28 11:53:39 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_ksh.c,v 1.1 2004/12/10 18:08:08 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: c_ksh.c,v 1.9 2004/10/28 11:53:39 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_ksh.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
int
c_cd(char **wp)

6
c_sh.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: c_sh.c,v 1.8 2004/12/10 22:21:24 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_sh.c,v 1.1 2004/12/10 18:08:08 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: c_sh.c,v 1.8 2004/12/10 22:21:24 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_sh.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
static char *clocktos(clock_t t);
@ -540,7 +540,7 @@ c_exitreturn(char **wp)
how = LSHELL;
}
quitenv(NULL); /* get rid of any i/o redirections */
quitenv(); /* get rid of any i/o redirections */
unwind(how);
/*NOTREACHED*/
return 0;

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_test.c,v 1.7 2004/10/28 11:53:39 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_test.c,v 1.1 2004/12/10 18:08:08 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: c_test.c,v 1.7 2004/10/28 11:53:39 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_test.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* test(1) accepts the following grammar:
oexpr ::= aexpr | aexpr "-o" oexpr ;

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_test.h,v 1.5 2004/10/28 11:53:40 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_test.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: c_test.h,v 1.2 2003/10/22 07:40:38 jmc Exp $ */
#ifndef C_TEST_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: c_ulimit.c,v 1.8 2004/10/28 11:53:40 tg Exp $ */
/** $MirBSD: src/bin/ksh/c_ulimit.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: c_ulimit.c,v 1.10 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -32,7 +32,7 @@ extern long ulimit();
# endif /* HAVE_ULIMIT */
#endif /* HAVE_ULIMIT_H */
__RCSID("$MirBSD: c_ulimit.c,v 1.8 2004/10/28 11:53:40 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/c_ulimit.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#define SOFT 0x1
#define HARD 0x2

4
chvt.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: chvt.c,v 1.6 2004/12/10 15:01:05 tg Exp $ */
/** $MirBSD: src/bin/ksh/chvt.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/*-
* Copyright (c) 2004
@ -24,7 +24,7 @@
#include <sys/ioctl.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: chvt.c,v 1.6 2004/12/10 15:01:05 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/chvt.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
char *
chvt(char *f)

View File

@ -1,4 +1,4 @@
/** $MirBSD: conf-end.h,v 1.9 2004/10/28 16:35:01 tg Exp $ */
/** $MirBSD: src/bin/ksh/conf-end.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: conf-end.h,v 1.2 1996/08/25 12:37:58 downsj Exp $ */
#ifndef CONF_END_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: config.h,v 1.15 2004/12/10 15:01:05 tg Exp $ */
/** $MirBSD: src/bin/ksh/config.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: config.h,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
/*

2
configure vendored
View File

@ -2,7 +2,7 @@
# Guess values for system-dependent variables and create Makefiles.
# Generated automatically using autoconf version 2.13.20040919
# $MirBSD: configure,v 1.16 2004/12/10 15:32:58 tg Exp $
# $MirBSD: src/bin/ksh/configure,v 1.1 2004/12/10 18:08:08 tg Exp $
# Copyright (C) 1992, 1993, 1994, 1995, 1996, 2004
# Free Software Foundation, Inc.
#

View File

@ -1,4 +1,4 @@
dnl $MirBSD: configure.in,v 1.10 2004/12/10 15:01:05 tg Exp $
dnl $MirBSD: src/bin/ksh/configure.in,v 1.1 2004/12/10 18:08:08 tg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl

4
edit.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: edit.c,v 1.10 2004/10/28 11:53:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/edit.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: edit.c,v 1.18 2003/08/22 18:17:10 fgsch Exp $ */
/*
@ -22,7 +22,7 @@
#include <ctype.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: edit.c,v 1.10 2004/10/28 11:53:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/edit.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#if defined(TIOCGWINSZ)
static RETSIGTYPE x_sigwinch(int sig);

2
edit.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: edit.h,v 1.5 2004/10/28 11:53:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/edit.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: edit.h,v 1.3 1999/11/14 22:04:02 d Exp $ */
/* $From: edit.h,v 1.2 1994/05/19 18:32:40 michael Exp michael $ */

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirBSD: emacs-gen.sh,v 1.3 2004/10/28 11:11:17 tg Exp $
# $MirBSD: src/bin/ksh/emacs-gen.sh,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: emacs-gen.sh,v 1.1.1.1 1996/08/14 06:19:10 downsj Exp $
case $# in

View File

@ -1,4 +1,4 @@
/** $MirBSD: emacs.c,v 1.12 2004/10/28 11:53:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/emacs.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: emacs.c,v 1.28 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -19,7 +19,7 @@
#include <locale.h>
#include "edit.h"
__RCSID("$MirBSD: emacs.c,v 1.12 2004/10/28 11:53:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/emacs.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
static Area aedit;
#define AEDIT &aedit /* area for kill ring and macro defns */

9
eval.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: eval.c,v 1.11 2004/12/10 22:21:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/eval.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: eval.c,v 1.16 2004/12/08 21:23:18 millert Exp $ */
/*
@ -10,7 +10,7 @@
#include "ksh_dir.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: eval.c,v 1.11 2004/12/10 22:21:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/eval.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/*
* string expansion
@ -287,12 +287,12 @@ expand(char *cp, XPtrV *wp, int f)
char endc;
char *str, *end;
sp = varname - 2; /* restore sp */
end = (char *) wdscan(sp, CSUBST);
/* ({) the } or x is already skipped */
endc = *end;
*end = EOS;
str = snptreef(NULL, 64, "%S", sp);
str = snptreef((char *) 0, 64, "%S",
varname - 1);
*end = endc;
errorf("%s: bad substitution", str);
}
@ -801,7 +801,6 @@ varsub(Expand *xp, char *sp, char *word, int *stypep, int *slenp)
case '=': /* can't assign to a vector */
case '%': /* can't trim a vector (yet) */
case '#':
case '?':
return -1;
}
XPinit(wv, 32);

21
exec.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: exec.c,v 1.7 2004/12/10 22:21:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/exec.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: exec.c,v 1.31 2003/12/15 05:25:52 otto Exp $ */
/*
@ -10,7 +10,7 @@
#include <ctype.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: exec.c,v 1.7 2004/12/10 22:21:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/exec.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* Does ps4 get parameter substitutions done? */
#ifdef KSH
@ -215,7 +215,7 @@ execute(struct op *volatile t, volatile int flags)
i = ksh_sigsetjmp(e->jbuf, 0);
if (i) {
sigprocmask(SIG_SETMASK, &omask, (sigset_t *) 0);
quitenv(NULL);
quitenv();
unwind(i);
/*NOTREACHED*/
}
@ -321,7 +321,7 @@ execute(struct op *volatile t, volatile int flags)
if ((e->flags&EF_BRKCONT_PASS)
|| (i != LBREAK && i != LCONTIN))
{
quitenv(NULL);
quitenv();
unwind(i);
} else if (i == LBREAK) {
rv = 0;
@ -361,7 +361,7 @@ execute(struct op *volatile t, volatile int flags)
if ((e->flags&EF_BRKCONT_PASS)
|| (i != LBREAK && i != LCONTIN))
{
quitenv(NULL);
quitenv();
unwind(i);
} else if (i == LBREAK) {
rv = 0;
@ -431,7 +431,7 @@ execute(struct op *volatile t, volatile int flags)
Break:
exstat = rv;
quitenv(NULL); /* restores IO */
quitenv(); /* restores IO */
if ((flags&XEXEC))
unwind(LEXIT); /* exit child */
if (rv != 0 && !(flags & XERROK)) {
@ -686,11 +686,11 @@ comexec(struct op *t, struct tbl *volatile tp, char **ap, volatile int flags)
case LEXIT:
case LLEAVE:
case LSHELL:
quitenv(NULL);
quitenv();
unwind(i);
/*NOTREACHED*/
default:
quitenv(NULL);
quitenv();
internal_errorf(1, "CFUNC %d", i);
}
break;
@ -1453,7 +1453,8 @@ herein(const char *content, int sub)
i = ksh_sigsetjmp(e->jbuf, 0);
if (i) {
source = osource;
quitenv(shf);
quitenv();
shf_close(shf); /* after quitenv */
close(fd);
return -2; /* special to iosetup(): don't print error */
}
@ -1469,7 +1470,7 @@ herein(const char *content, int sub)
} else
shf_puts(content, shf);
quitenv(NULL);
quitenv();
if (shf_close(shf) == EOF) {
close(fd);

View File

@ -1,4 +1,4 @@
/** $MirBSD: expand.h,v 1.6 2004/10/28 11:53:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/expand.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: expand.h,v 1.3 2001/03/26 16:19:45 todd Exp $ */
#ifndef EXPAND_H

8
expr.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: expr.c,v 1.8 2004/12/10 22:21:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/expr.c,v 1.1 2004/12/10 18:08:08 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: expr.c,v 1.8 2004/12/10 22:21:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/expr.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* The order of these enums is constrained by the order of opinfo[] */
enum token {
@ -176,7 +176,7 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok)
/* Clear EXPRINEVAL in of any variables we were playing with */
if (curstate.evaling)
curstate.evaling->flag &= ~EXPRINEVAL;
quitenv(NULL);
quitenv();
if (i == LAEXPR) {
if (error_ok == KSH_RETURN_ERROR)
return 0;
@ -202,7 +202,7 @@ v_evaluate(struct tbl *vp, const char *expr, volatile int error_ok)
/* can fail if readonly */
setstr(vp, str_val(v), error_ok);
quitenv(NULL);
quitenv();
return 1;
}

View File

@ -1,4 +1,4 @@
/** $MirBSD: history.c,v 1.14 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/history.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: history.c,v 1.24 2004/08/03 12:44:59 danh Exp $ */
/*
@ -21,7 +21,7 @@
#include "sh.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: history.c,v 1.14 2004/10/28 11:53:42 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/history.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#ifdef HISTORY
# ifdef EASY_HISTORY

2
io.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: io.c,v 1.7 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/io.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: io.c,v 1.13 2003/11/10 21:26:39 millert Exp $ */
/*

4
jobs.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: jobs.c,v 1.8 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/jobs.c,v 1.1 2004/12/10 18:08:08 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: jobs.c,v 1.8 2004/10/28 11:53:42 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/jobs.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* Start of system configuration stuff */

View File

@ -1,4 +1,4 @@
.\" $MirBSD: ksh.1tbl,v 1.45 2004/12/10 16:01:34 tg Exp $
.\" $MirBSD: src/bin/ksh/ksh.1tbl,v 1.1 2004/12/10 18:08:08 tg Exp $
.\" $OpenBSD: ksh.1tbl,v 1.79 2004/12/04 07:05:13 jaredy Exp $
.\" $OpenBSD: sh.1tbl,v 1.52 2004/11/09 21:56:54 jmc Exp $
.\"

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_dir.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/ksh_dir.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: ksh_dir.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */
#ifndef KSH_DIR_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_limval.h,v 1.4 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/ksh_limval.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: ksh_limval.h,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $ */
#ifndef KSH_LIMVAL_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_stat.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/ksh_stat.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: ksh_stat.h,v 1.3 1996/10/01 02:05:39 downsj Exp $ */
#ifndef KSH_STAT_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_time.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/ksh_time.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: ksh_time.h,v 1.2 1996/10/01 02:05:40 downsj Exp $ */
#ifndef KSH_TIME_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_times.h,v 1.5 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/ksh_times.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: ksh_times.h,v 1.2 1996/10/01 02:05:41 downsj Exp $ */
#ifndef KSH_TIMES_H

View File

@ -1,4 +1,4 @@
/** $MirBSD: ksh_wait.h,v 1.4 2004/10/28 11:53:42 tg Exp $ */
/** $MirBSD: src/bin/ksh/ksh_wait.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: ksh_wait.h,v 1.3 1997/06/19 13:58:43 kstailey Exp $ */
#ifndef KSH_WAIT_H

6
lex.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: lex.c,v 1.8 2004/12/10 22:21:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/lex.c,v 1.1 2004/12/10 18:08:08 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: lex.c,v 1.8 2004/12/10 22:21:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/lex.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* Structure to keep track of the lexing state and the various pieces of info
* needed for each particular state.
@ -1140,7 +1140,7 @@ set_prompt(int to, Source *s)
} else
prompt = str_save(substitute(ps1, 0),
saved_atemp);
quitenv(NULL);
quitenv();
}
#else /* KSH */
prompt = str_val(global("PS1"));

2
lex.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: lex.h,v 1.5 2004/11/03 15:33:01 tg Exp $ */
/** $MirBSD: src/bin/ksh/lex.h,v 1.1 2004/12/10 18:08:08 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 $ */

28
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: main.c,v 1.16 2004/12/10 22:21:25 tg Exp $ */
/** $MirBSD: src/bin/ksh/main.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
/*
@ -11,7 +11,7 @@
#include "ksh_stat.h"
#include "ksh_time.h"
__RCSID("$MirBSD: main.c,v 1.16 2004/12/10 22:21:25 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/main.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
extern char **environ;
@ -479,7 +479,9 @@ include(const char *name, int argc, char **argv, int intr_ok)
newenv(E_INCL);
i = ksh_sigsetjmp(e->jbuf, 0);
if (i) {
quitenv(s ? s->u.shf : NULL);
if (s) /* Do this before quitenv(), which frees the memory */
shf_close(s->u.shf);
quitenv();
if (old_argv) {
e->loc->argv = old_argv;
e->loc->argc = old_argc;
@ -513,7 +515,8 @@ include(const char *name, int argc, char **argv, int intr_ok)
s->u.shf = shf;
s->file = str_save(name, ATEMP);
i = shell(s, FALSE);
quitenv(s->u.shf);
shf_close(s->u.shf);
quitenv();
if (old_argv) {
e->loc->argv = old_argv;
e->loc->argc = old_argc;
@ -579,12 +582,12 @@ shell(Source *volatile s, volatile int toplevel)
case LLEAVE:
case LRETURN:
source = old_source;
quitenv(NULL);
quitenv();
unwind(i); /* keep on going */
/*NOREACHED*/
default:
source = old_source;
quitenv(NULL);
quitenv();
internal_errorf(1, "shell: %d", i);
/*NOREACHED*/
}
@ -636,7 +639,7 @@ shell(Source *volatile s, volatile int toplevel)
reclaim();
}
quitenv(NULL);
quitenv();
source = old_source;
return exstat;
}
@ -671,7 +674,7 @@ unwind(int i)
/* Fall through... */
default:
quitenv(NULL);
quitenv();
}
}
}
@ -693,7 +696,7 @@ newenv(int type)
}
void
quitenv(struct shf *shf)
quitenv(void)
{
struct env *ep = e;
int fd;
@ -708,6 +711,7 @@ quitenv(struct shf *shf)
if (ep->savefd[2]) /* Clear any write errors */
shf_reopen(2, SHF_WR, shl_out);
}
reclaim();
/* Bottom of the stack.
* Either main shell is exiting or cleanup_parents_env() was called.
@ -736,14 +740,8 @@ quitenv(struct shf *shf)
chmem_allfree();
#endif /* MEM_DEBUG */
}
if (shf)
shf_close(shf);
reclaim();
exit(exstat);
}
if (shf)
shf_close(shf);
reclaim();
e = e->oenv;
afree(ep, ATEMP);

4
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: misc.c,v 1.14 2004/10/31 23:01:18 tg Exp $ */
/** $MirBSD: src/bin/ksh/misc.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -11,7 +11,7 @@
# include <limits.h>
#endif
__RCSID("$MirBSD: misc.c,v 1.14 2004/10/31 23:01:18 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF

View File

@ -1,4 +1,4 @@
/** $MirBSD: missing.c,v 1.3 2004/09/21 11:57:13 tg Exp $ */
/** $MirBSD: src/bin/ksh/missing.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: missing.c,v 1.5 2003/05/16 18:49:46 jsyn Exp $ */
/*

4
path.c
View File

@ -1,10 +1,10 @@
/** $MirBSD: path.c,v 1.7 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/path.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: path.c,v 1.9 2003/10/22 07:40:38 jmc Exp $ */
#include "sh.h"
#include "ksh_stat.h"
__RCSID("$MirBSD: path.c,v 1.7 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/path.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/*
* Contains a routine to search a : separated list of

View File

@ -1,4 +1,4 @@
/** $MirBSD: proto.h,v 1.11 2004/12/10 22:21:26 tg Exp $ */
/** $MirBSD: src/bin/ksh/proto.h,v 1.1 2004/12/10 18:08:08 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 $ */
@ -171,7 +171,7 @@ int command(const char *comm);
int shell(Source *volatile s, int volatile toplevel);
void unwind(int i) GCC_FUNC_ATTR(noreturn);
void newenv(int type);
void quitenv(struct shf *shf);
void quitenv(void);
void cleanup_parents_env(void);
void cleanup_proc_env(void);
void aerror(Area *ap, const char *msg)

4
rnd.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: rnd.c,v 1.8 2004/12/05 16:10:58 tg Exp $ */
/** $MirBSD: src/bin/ksh/rnd.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/*-
* Copyright (c) 2004
@ -23,7 +23,7 @@
#include "sh.h"
#include "proto.h"
__RCSID("$MirBSD: rnd.c,v 1.8 2004/12/05 16:10:58 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/rnd.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#ifndef HAVE_SRANDOM
#undef HAVE_RANDOM

View File

@ -1,4 +1,4 @@
.\" $MirBSD: sh.1tbl,v 1.11 2004/11/10 17:22:13 tg Exp $
.\" $MirBSD: src/bin/ksh/sh.1tbl,v 1.1 2004/12/10 18:08:08 tg Exp $
.\" _MirBSD: src/bin/ksh/ksh.1tbl,v 1.41 2004/11/10 17:18:29 tg Exp $
.\" $OpenBSD: ksh.1tbl,v 1.78 2004/11/08 23:42:02 jmc Exp $
.\" $OpenBSD: sh.1tbl,v 1.52 2004/11/09 21:56:54 jmc Exp $

2
sh.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: sh.h,v 1.19 2004/11/10 19:58:06 tg Exp $ */
/** $MirBSD: src/bin/ksh/sh.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: sh.h,v 1.18 2004/05/31 10:36:35 otto Exp $ */
#ifndef SH_H

4
shf.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: shf.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/shf.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: shf.c,v 1.8 2003/02/28 09:45:09 jmc Exp $ */
/*
@ -9,7 +9,7 @@
#include "ksh_stat.h"
#include "ksh_limval.h"
__RCSID("$MirBSD: shf.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/shf.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* flags to shf_emptybuf() */
#define EB_READSW 0x01 /* about to switch to reading */

2
shf.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: shf.h,v 1.5 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/shf.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: shf.h,v 1.2 1999/01/08 20:25:02 millert Exp $ */
#ifndef SHF_H

View File

@ -1,4 +1,4 @@
# $MirBSD: siglist.in,v 1.2 2004/05/24 19:56:18 tg Stab $
# $MirBSD: src/bin/ksh/siglist.in,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: siglist.in,v 1.1.1.1 1996/08/14 06:19:11 downsj Exp $
#
# List of signals used to initialize ksh's signal table (see trap.c

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirBSD: siglist.sh,v 1.3 2004/10/28 11:03:24 tg Exp $
# $MirBSD: src/bin/ksh/siglist.sh,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: siglist.sh,v 1.4 1997/06/19 13:58:47 kstailey Exp $
#
# Script to generate a sorted, complete list of signals, suitable

129
strlfun.c Normal file
View File

@ -0,0 +1,129 @@
/** $MirBSD: src/bin/ksh/strlfun.c,v 1.1 2004/12/10 18:12:29 tg Exp $ */
/** _MirBSD: src/lib/libc/string/strlfun.c,v 1.7 2004/12/05 16:07:53 tg Exp $ */
/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */
/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */
/*-
* Copyright (c) 2004
* Thorsten "mirabile" Glaser <tg@66h.42h.de>
*
* Licensee is hereby permitted to deal in this work without restric-
* tion, including unlimited rights to use, publicly perform, modify,
* merge, distribute, sell, give away or sublicence, provided all co-
* pyright notices above, these terms and the disclaimer are retained
* in all redistributions or reproduced in accompanying documentation
* or other materials provided with binary redistributions.
*
* Licensor hereby provides this work "AS IS" and WITHOUT WARRANTY of
* any kind, expressed or implied, to the maximum extent permitted by
* applicable law, but with the warranty of being written without ma-
* licious intent or gross negligence; in no event shall licensor, an
* author or contributor be held liable for any damage, direct, indi-
* rect or other, however caused, arising in any way out of the usage
* of this work, even if advised of the possibility of such damage.
*-
* Implementation for most of this code by myself.
* Some optimisation ideas from Bodo Eggert (via d.a.s.r).
* The rest of the code is covered by the terms below:
*-
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
*
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
*
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
#include <sys/types.h>
#include <string.h>
#ifdef HAVE_CONFIG_H
/* packaged with third-party software */
#include "config.h"
#define LIBC_SCCS
#else /* ! def HAVE_CONFIG_H */
/* integrated into MirOS C library */
#undef HAVE_STRLCPY
#undef HAVE_STRLCAT
#endif /* ! def HAVE_CONFIG_H */
#ifndef __RCSID
#define __RCSID(x) static const char __rcsid[] = (x)
#endif
__RCSID("$MirBSD: src/bin/ksh/strlfun.c,v 1.1 2004/12/10 18:12:29 tg Exp $");
#ifndef HAVE_STRLCPY
/*
* Copy src to string dst of size siz. At most siz-1 characters
* will be copied. Always NUL terminates (unless siz == 0).
* Returns strlen(src); if retval >= siz, truncation occurred.
*/
size_t
strlcpy(char *dst, const char *src, size_t siz)
{
const char *s = src;
if (!siz) goto traverse_src;
/* Copy as many bytes as will fit */
for (; --siz && (*dst++ = *s++); /* nothing */)
;
/* Not enough room in dst, add NUL and traverse rest of src */
if (!siz) {
/* Save, since we've copied at max. (siz-1) characters */
*dst = '\0'; /* NUL-terminate dst */
traverse_src:
while (*s++)
;
}
return (s - src - 1); /* count does not include NUL */
}
#endif /* ndef HAVE_STRLCPY */
#ifndef HAVE_STRLCAT
/*
* Appends src to string dst of size siz (unlike strncat, siz is the
* full size of dst, not space left). At most siz-1 characters
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
* If retval >= siz, truncation occurred.
*/
size_t
strlcat(char *dst, const char *src, size_t siz)
{
char *d = dst;
size_t dl, n = siz;
const size_t sl = strlen(src);
while (n-- && (*d++ != '\0'))
;
if (!++n && (*d != '\0'))
return strlen(src);
dl = --d - dst; /* original strlen(dst), max. siz-1 */
n = siz - dl;
dl += sl;
if (!n--)
return dl;
if (n > sl)
n = sl; /* number of octets to copy */
for (; n-- && (*d++ = *src++); /* nothing */)
;
*d = '\0'; /* NUL-terminate dst */
return dl;
}
#endif /* ndef HAVE_STRLCAT */

4
syn.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: syn.c,v 1.7 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/syn.c,v 1.1 2004/12/10 18:08:08 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: syn.c,v 1.7 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/syn.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
struct nesting_state {
int start_token; /* token than began nesting (eg, FOR) */

View File

@ -1,4 +1,4 @@
/** $MirBSD: table.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/table.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: table.c,v 1.5 1999/01/10 17:55:03 millert Exp $ */
/*
@ -7,7 +7,7 @@
#include "sh.h"
__RCSID("$MirBSD: table.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/table.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#define INIT_TBLS 8 /* initial table size (power of 2) */

View File

@ -1,4 +1,4 @@
/** $MirBSD: table.h,v 1.6 2004/11/10 17:13:11 tg Exp $ */
/** $MirBSD: src/bin/ksh/table.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: table.h,v 1.5 1999/06/15 01:18:36 millert Exp $ */
/* $From: table.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */

View File

@ -1,4 +1,4 @@
# $MirBSD: bksl-nl.t,v 1.3 2004/11/01 12:27:22 tg Exp $
# $MirBSD: src/bin/ksh/tests/bksl-nl.t,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: bksl-nl.t,v 1.2 2001/01/28 23:04:56 niklas Exp $
#
# These tests deal with how \newline is handled in various situations. The

View File

@ -1,4 +1,4 @@
# $MirBSD: history.t,v 1.2 2004/05/24 19:56:25 tg Stab $
# $MirBSD: src/bin/ksh/tests/history.t,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: history.t,v 1.5 2001/01/28 23:04:56 niklas Exp $
#
# Not tested yet:

View File

@ -1,4 +1,4 @@
# $MirBSD: read.t,v 1.2 2004/05/24 19:56:25 tg Stab $
# $MirBSD: src/bin/ksh/tests/read.t,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: read.t,v 1.3 2003/03/10 03:48:16 david Exp $
#
# To test:

View File

@ -1,4 +1,4 @@
# $MirBSD: regress.t,v 1.2 2004/05/24 19:56:25 tg Stab $
# $MirBSD: src/bin/ksh/tests/regress.t,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: regress.t,v 1.12 2003/11/08 19:17:27 jmc Exp $
#
# The first 39 of these tests are from the old Bugs script.

View File

@ -1,5 +1,5 @@
#!/usr/bin/perl
# $MirBSD: th,v 1.2 2004/05/24 19:56:25 tg Stab $
# $MirBSD: src/bin/ksh/tests/th,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: th,v 1.10 2003/09/01 05:16:46 fgsch Exp $
#
# Test harness for pdksh tests.

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirBSD: th.sh,v 1.2 2004/05/24 19:56:25 tg Stab $
# $MirBSD: src/bin/ksh/tests/th.sh,v 1.1 2004/12/10 18:08:08 tg Exp $
# $OpenBSD: th.sh,v 1.4 2001/01/28 23:04:57 niklas Exp $
#
# Simple script to find perl and run it

4
trap.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: trap.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/trap.c,v 1.1 2004/12/10 18:08:08 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: trap.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/trap.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/* Table is indexed by signal number
*

4
tree.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: tree.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/tree.c,v 1.1 2004/12/10 18:08:08 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: tree.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/tree.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#define INDENT 4

2
tree.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: tree.h,v 1.4 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/tree.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: tree.h,v 1.8 2003/10/22 07:40:38 jmc Exp $ */
/* $From: tree.h,v 1.3 1994/05/31 13:34:34 michael Exp $ */

4
tty.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: tty.c,v 1.6 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/tty.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: tty.c,v 1.2 1996/10/01 02:05:51 downsj Exp $ */
#include "sh.h"
@ -7,7 +7,7 @@
#include "tty.h"
#undef EXTERN
__RCSID("$MirBSD: tty.c,v 1.6 2004/10/28 11:53:43 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/tty.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
int
get_tty(int fd, TTY_state *ts)

2
tty.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: tty.h,v 1.5 2004/10/28 11:53:43 tg Exp $ */
/** $MirBSD: src/bin/ksh/tty.h,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: tty.h,v 1.2 1996/11/21 07:59:36 downsj Exp $ */
#ifndef TTY_H

4
var.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: var.c,v 1.12 2004/11/10 17:13:11 tg Exp $ */
/** $MirBSD: src/bin/ksh/var.c,v 1.1 2004/12/10 18:08:08 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: var.c,v 1.12 2004/11/10 17:13:11 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/var.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
/*
* Variables

View File

@ -1,4 +1,4 @@
/** $MirBSD: version.c,v 1.18 2004/12/09 20:08:48 tg Exp $ */
/** $MirBSD: src/bin/ksh/version.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: version.c,v 1.12 1999/07/14 13:37:24 millert Exp $ */
/*-

4
vi.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: vi.c,v 1.10 2004/10/28 11:53:44 tg Exp $ */
/** $MirBSD: src/bin/ksh/vi.c,v 1.1 2004/12/10 18:08:08 tg Exp $ */
/* $OpenBSD: vi.c,v 1.13 2004/05/10 16:28:47 pvalchev Exp $ */
/*
@ -15,7 +15,7 @@
#include "ksh_stat.h" /* completion */
#include "edit.h"
__RCSID("$MirBSD: vi.c,v 1.10 2004/10/28 11:53:44 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/vi.c,v 1.1 2004/12/10 18:08:08 tg Exp $");
#define Ctrl(c) (c&0x1f)
#define is_wordch(c) (letnum(c))