* reduce amount of empty lines

* replace some spaces by tabs
* shuffle code around (shrink)
This commit is contained in:
tg 2004-12-13 18:53:25 +00:00
parent f4b8bc819c
commit 978a1d53a1
13 changed files with 309 additions and 407 deletions

View File

@ -1,5 +1,5 @@
#!/bin/sh
# $MirBSD: src/bin/ksh/Build.sh,v 2.2 2004/12/13 17:33:35 tg Exp $
# $MirBSD: src/bin/ksh/Build.sh,v 2.3 2004/12/13 18:53:25 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 -DMKSH"
CPPFLAGS="$CPPFLAGS -DHAVE_CONFIG_H -I. -DKSH"
COPTS="-O2 -fomit-frame-pointer -fno-strict-aliasing -fno-strength-reduce"
[ -z "$WEIRD_OS" ] && LDFLAGS="${LDFLAGS:--static}"

View File

@ -1,133 +1,133 @@
$MirBSD: src/bin/ksh/CONTRIBUTORS,v 2.1 2004/12/10 18:09:40 tg Exp $
$MirBSD: src/bin/ksh/CONTRIBUTORS,v 2.2 2004/12/13 18:53:25 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
readmes (most of which are still in the misc directory) and the source
code. Hopefully it is correct and no contributors have been left out
readmes and source code.
Hopefully it is correct and no contributors have been left out
(file a bug report if you spot a problem :-)).
Release history:
* Eric Gisin (egisin@math.uwaterloo.ca), created pdksh, using
Charles Forsyth's public domain V7 shell as a base; also used parts
of the BRL shell (written by Doug A Gwyn, Doug Kingston, Ron Natalie,
Arnold Robbins, Lou Salkind, and others?, circa '87; the parts used in
pdksh included getopts, test builtin, ulimit, tty setting/getting, emacs
editing, and job control; the test builtin was based on code by Erik
Baalbergen).
'87..'89 ?
Released versions: .. 3.2
* John R MacMillan (@yonge.csri.toronto.edu:chance!john@sq.sq.com)
takes over as maintainer
dates?
Released versions: 3.3 (?)
* Simon J. Gerraty (sjg@zen.void.oz.au) takes over as maintainer
Nov '91..July '94 ?
Released versions: 4.0 .. 4.9
* Michael Rendell (michael@cs.mun.ca) takes over as maintainer
July, 1994
Released versions: 5.0 .. 5.2
* Thorsten Glaser (tg@66h.42h.de) releases mirbsdksh and is the guy
to blame for all mirbsdksh-specific or MirOS-specific bugs.
Released versions: 5.2.14 MirOS 1.1-1.x
* Eric Gisin (egisin@math.uwaterloo.ca), created pdksh, using
Charles Forsyth's public domain V7 shell as a base; also used parts
of the BRL shell (written by Doug A Gwyn, Doug Kingston, Ron Natalie,
Arnold Robbins, Lou Salkind, and others?, circa '87; the parts used in
pdksh included getopts, test builtin, ulimit, tty setting/getting, emacs
editing, and job control; the test builtin was based on code by Erik
Baalbergen).
'87..'89 ?
Released versions: .. 3.2
* John R MacMillan (@yonge.csri.toronto.edu:chance!john@sq.sq.com)
takes over as maintainer
dates?
Released versions: 3.3 (?)
* Simon J. Gerraty (sjg@zen.void.oz.au) takes over as maintainer
Nov '91..July '94 ?
Released versions: 4.0 .. 4.9
* Michael Rendell (michael@cs.mun.ca) takes over as maintainer
July, 1994
Released versions: 5.0 .. 5.2
* Thorsten Glaser (tg@66h.42h.de) releases mksh and is the guy
to blame for all mirbsdksh-specific or MirOS-specific bugs.
Released versions: 5.2.14 MirOS 1.1-1.x
Major contributions:
* John R MacMillan (@yonge.csri.toronto.edu:chance!john@sq.sq.com), ?:
cleaned up configuration, many bug fixes (see misc/Changes.jrm).
* Simon Gerraty, (sjg@zen.void.oz.au), Nov '91..?: much improved emacs mode
ala at&t ksh, 386bsd port, sigaction routines for non-POSIX systems
(see misc/ChangeLog.sjg and misc/ReadME.sjg).
* Peter Collinson (pc@hillside.co.uk), July '92: added select, at&t ksh
style history file, original csh-style {} globbing, BSD/386 port,
misc bug fixes.
* Larry Bouzane (larry@compusult.nf.ca), Mar '89..'93: re-wrote job control,
added async job notification, added CDPATH and other cd fixes, misc bug
fixes.
* John Rochester (jr@cs.mun.ca), '87: wrote vi command line editor; various
bug fixes/enhancements.
* Jeff Sparkes (jsparkes@bnr.ca), Mar '89..Mar '90: added arrays,
merged John Rochester's vi code into pdksh, misc bug fixes.
* Michael Haardt (u31b3hs@POOL.Informatik.RWTH-Aachen.DE), Sept '94:
organized man page, filled in many of its copious blank spots; added
KSH ifdefs.
* Dale DePriest (daled@cadence.com): ported to OS/2 (initially based on
port of pdksh4.9 to OS/2 by Kai Rommel (rommel@ars.muc.de)); maintains
OS/2 port; misc bug fixes.
* John R MacMillan (@yonge.csri.toronto.edu:chance!john@sq.sq.com), ?:
cleaned up configuration, many bug fixes (see misc/Changes.jrm).
* Simon Gerraty, (sjg@zen.void.oz.au), Nov '91..?: much improved emacs mode
ala at&t ksh, 386bsd port, sigaction routines for non-POSIX systems
(see misc/ChangeLog.sjg and misc/ReadME.sjg).
* Peter Collinson (pc@hillside.co.uk), July '92: added select, at&t ksh
style history file, original csh-style {} globbing, BSD/386 port,
misc bug fixes.
* Larry Bouzane (larry@compusult.nf.ca), Mar '89..'93: re-wrote job control,
added async job notification, added CDPATH and other cd fixes, misc bug
fixes.
* John Rochester (jr@cs.mun.ca), '87: wrote vi command line editor; various
bug fixes/enhancements.
* Jeff Sparkes (jsparkes@bnr.ca), Mar '89..Mar '90: added arrays,
merged John Rochester's vi code into pdksh, misc bug fixes.
* Michael Haardt (u31b3hs@POOL.Informatik.RWTH-Aachen.DE), Sept '94:
organized man page, filled in many of its copious blank spots; added
KSH ifdefs.
* Dale DePriest (daled@cadence.com): ported to OS/2 (initially based on
port of pdksh4.9 to OS/2 by Kai Rommel (rommel@ars.muc.de)); maintains
OS/2 port; misc bug fixes.
Other contributors:
* Piercarlo Grandi (pcg@aber.ac.uk), Dec '93: fixes for linux port
* Neil Smithline (Neil.Smithline@eng.sun.com), Aug '92: emacs-style
filename completion.
* Mike Jetzer [mlj] (jetzer@studsys.mscs.mu.edu), ?;Nov '94: fixes for vi
mode (see misc/Changes.mlj), added v to vi, fixes for history; fixed
command redoing in vi; fixes to vi globbing.
* Robert J Gibson: mailbox checking code that was adapted for pdksh by
John R. MacMillan.
* ? (guy@demon.co.uk), ?: promptlen() function.
* J.T. Conklin (jtc@cygnus.com): POSIXized test builtin; miscellaneous
fixes/enhancements.
* Sean Hogan (sean@neweast.ca): fixes for ICS 3.0 Unix, found and helped
fix numerous problems.
* Gordan Larson (hoh@approve.se): fix to compile sans VI, ksh.1 typo.
* Thomas Gellekum (thomas@ghpc8.ihf.rwth-aachen.de): fixes for Makefile
typos, fixed CLK_TCK for FreeBSD, man page fixes.
* Ed Ferguson (Ed.Ferguson@dseg.ti.com): fix to compile sans VI.
* Brian Campbell (brianc@qnx.com): fixes to compile under QNX and
to compile with dmake.
* (guy@netapp.com), Oct '94: patch to use gmacs flag.
* Andrew Moore (alm@netcom.com): reported many bugs, fixes.
* William Bader (wbader@CSEE.Lehigh.Edu): fix to compile on SCO Unix
(strut winsize).
* Mike Long (mike.long@analog.com): makefile fix - use $manext, not 1.
* Art Mills (aem@hpbs9162.bio.hp.com): bug fix for vi file completion in
command mode.
* Tory Bollinger (tboll@authstin.ibm.com): allow ~ in vi mode to take
a count.
* Frank Edwards (<crash@azhrei.EEC.COM>): added macros to vi (@char).
* Fritz Heinrichmeyer (<Fritz.Heinrichmeyer@FernUni-Hagen.de>): fixes
to allow compile under Linux 1.4.3.
* Gabor Zahemszky (<zgabor@CoDe.hu>): SVR3_PGRP vs SYSV_PGRP, many
bug reports and man page fixes.
* Dave Kinchlea (<kinch@julian.uwo.ca>): DEFAULT_ENV patches.
* Paul Borman (<prb@bsdi.com>): j_exit: send HUP, then CONT; HUP fg process.
* DaviD W. Sanderson (<dws@ssec.wisc.edu>): patches to allow { .. } instead
of in .. esac in case statements.
* ? (<ra@rhi.hi.is>): partial patches to handle SIGWINCH for command line
editing.
* Jason Tyler (<jason@nc.bhpese.oz.au>): fixes for bugs in fc.
* Stefan Dalibor (<Stefan.Dalibor@informatik.uni-erlangen.de>): fix for
COLUMNS never being set in x_init().
* Arnon Kanfi (<arnon@gilly.datatools.com>): fix for prompt.
* Marc Olzheim (<marcolz@stack.nl>): patches to ifdef KSH the mail check
code and aliases; enum patches for old K&R compilers; handle missing dup2.
* Lars Hecking (<lhecking@nmrc.ucc.ie>): fixes so shell compiles as sh
again.
* Bill Kish (<kish@browncow.com>): added prompt delimiter hack for
hidden characters (eg, escape codes).
* Andrew S. Townley (<atownley@informix.com>): fixes for NeXT machines:
get a controlling if one needed, use correct profile.
* Eric J. Chet (<ejc@bazzle.com>): fix for core dump in . (quitenv() called
too soon).
* Greg A. Woods <woods@most.weird.com>: fix to make ^[_ in emacs work
as in at&t ksh.
* George Robbins <grr@shandakor.tharsis.com>: fix for sh mode to
keep exec'd file descriptors open.
* George White <gwhite@bodnext.bio.dfo.ca>: fix here-doc problem under OS/2
(memory allocated incorrectly).
* David E. Wexelblat <dwex@DataFocus.com>: fix to avoid memory overrun
in aresize(); fix to not print un-named options.
* Clifford Wolf (<clifford@clifford.at>): fix memory overrun in aresize();
fixed sys_siglist[] problem.
* Theo de Raadt (<deraadt@cvs.openbsd.org>): allow ". /dev/null".
* Eric Youngdale (<ericy@datafocus.com>): flag field incorrectly changed
in exec.c(flushcom).
* Todd. C Miller (Todd C. Miller <Todd.Miller@courtesan.com>): fix
for coredump in jobs.
* Kevin Schoedel <schoedel@kw.igs.net>: fix for word location in file
completion.
* Martin Lucina <mato@kotelna.sk>: fix for argument parsing in exit command,
fix for KSH_CHECK_H_TYPE.
* Mark Funkenhauser <mark@interix.com>: added $LINENO support.
* Corinna Vinschen <Corinna@Vinschen.de> and Steven Hein <ssh@sgi.com>:
port to cyngin environment on win95/winnt.
* Martin Dalecki <dalecki@cs.net.pl>: changes for 8 bit emacs mode.
* Dave Hillman <daveh@gte.net>: patch for bug in test -nt.
* Piercarlo Grandi (pcg@aber.ac.uk), Dec '93: fixes for linux port
* Neil Smithline (Neil.Smithline@eng.sun.com), Aug '92: emacs-style
filename completion.
* Mike Jetzer [mlj] (jetzer@studsys.mscs.mu.edu), ?;Nov '94: fixes for vi
mode (see misc/Changes.mlj), added v to vi, fixes for history; fixed
command redoing in vi; fixes to vi globbing.
* Robert J Gibson: mailbox checking code that was adapted for pdksh by
John R. MacMillan.
* ? (guy@demon.co.uk), ?: promptlen() function.
* J.T. Conklin (jtc@cygnus.com): POSIXized test builtin; miscellaneous
fixes/enhancements.
* Sean Hogan (sean@neweast.ca): fixes for ICS 3.0 Unix, found and helped
fix numerous problems.
* Gordan Larson (hoh@approve.se): fix to compile sans VI, ksh.1 typo.
* Thomas Gellekum (thomas@ghpc8.ihf.rwth-aachen.de): fixes for Makefile
typos, fixed CLK_TCK for FreeBSD, man page fixes.
* Ed Ferguson (Ed.Ferguson@dseg.ti.com): fix to compile sans VI.
* Brian Campbell (brianc@qnx.com): fixes to compile under QNX and
to compile with dmake.
* (guy@netapp.com), Oct '94: patch to use gmacs flag.
* Andrew Moore (alm@netcom.com): reported many bugs, fixes.
* William Bader (wbader@CSEE.Lehigh.Edu): fix to compile on SCO Unix
(strut winsize).
* Mike Long (mike.long@analog.com): makefile fix - use $manext, not 1.
* Art Mills (aem@hpbs9162.bio.hp.com): bug fix for vi file completion in
command mode.
* Tory Bollinger (tboll@authstin.ibm.com): allow ~ in vi mode to take
a count.
* Frank Edwards (<crash@azhrei.EEC.COM>): added macros to vi (@char).
* Fritz Heinrichmeyer (<Fritz.Heinrichmeyer@FernUni-Hagen.de>): fixes
to allow compile under Linux 1.4.3.
* Gabor Zahemszky (<zgabor@CoDe.hu>): SVR3_PGRP vs SYSV_PGRP, many
bug reports and man page fixes.
* Dave Kinchlea (<kinch@julian.uwo.ca>): DEFAULT_ENV patches.
* Paul Borman (<prb@bsdi.com>): j_exit: send HUP, then CONT; HUP fg process.
* DaviD W. Sanderson (<dws@ssec.wisc.edu>): patches to allow { .. } instead
of in .. esac in case statements.
* ? (<ra@rhi.hi.is>): partial patches to handle SIGWINCH for command line
editing.
* Jason Tyler (<jason@nc.bhpese.oz.au>): fixes for bugs in fc.
* Stefan Dalibor (<Stefan.Dalibor@informatik.uni-erlangen.de>): fix for
COLUMNS never being set in x_init().
* Arnon Kanfi (<arnon@gilly.datatools.com>): fix for prompt.
* Marc Olzheim (<marcolz@stack.nl>): patches to ifdef KSH the mail check
code and aliases; enum patches for old K&R compilers; handle missing dup2.
* Lars Hecking (<lhecking@nmrc.ucc.ie>): fixes so shell compiles as sh
again.
* Bill Kish (<kish@browncow.com>): added prompt delimiter hack for
hidden characters (eg, escape codes).
* Andrew S. Townley (<atownley@informix.com>): fixes for NeXT machines:
get a controlling if one needed, use correct profile.
* Eric J. Chet (<ejc@bazzle.com>): fix for core dump in . (quitenv() called
too soon).
* Greg A. Woods <woods@most.weird.com>: fix to make ^[_ in emacs work
as in at&t ksh.
* George Robbins <grr@shandakor.tharsis.com>: fix for sh mode to
keep exec'd file descriptors open.
* George White <gwhite@bodnext.bio.dfo.ca>: fix here-doc problem under OS/2
(memory allocated incorrectly).
* David E. Wexelblat <dwex@DataFocus.com>: fix to avoid memory overrun
in aresize(); fix to not print un-named options.
* Clifford Wolf (<clifford@clifford.at>): fix memory overrun in aresize();
fixed sys_siglist[] problem.
* Theo de Raadt (<deraadt@cvs.openbsd.org>): allow ". /dev/null".
* Eric Youngdale (<ericy@datafocus.com>): flag field incorrectly changed
in exec.c(flushcom).
* Todd. C Miller (Todd C. Miller <Todd.Miller@courtesan.com>): fix
for coredump in jobs.
* Kevin Schoedel <schoedel@kw.igs.net>: fix for word location in file
completion.
* Martin Lucina <mato@kotelna.sk>: fix for argument parsing in exit command,
fix for KSH_CHECK_H_TYPE.
* Mark Funkenhauser <mark@interix.com>: added $LINENO support.
* Corinna Vinschen <Corinna@Vinschen.de> and Steven Hein <ssh@sgi.com>:
port to cyngin environment on win95/winnt.
* Martin Dalecki <dalecki@cs.net.pl>: changes for 8 bit emacs mode.
* Dave Hillman <daveh@gte.net>: patch for bug in test -nt.

View File

@ -1,11 +1,10 @@
# $MirBSD: src/bin/ksh/Makefile,v 2.2 2004/12/13 16:50:50 tg Exp $
# $MirBSD: src/bin/ksh/Makefile,v 2.3 2004/12/13 18:53:25 tg Exp $
# $OpenBSD: Makefile,v 1.18 2004/02/16 19:07:19 deraadt Exp $
PROG= ksh
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c chvt.c edit.c \
emacs.c eval.c exec.c expr.c history.c io.c jobs.c lex.c \
main.c misc.c missing.c path.c rnd.c shf.c syn.c table.c \
trap.c tree.c tty.c var.c version.c vi.c
SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \
exec.c expr.c history.c io.c jobs.c lex.c main.c misc.c missing.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

24
NOTES
View File

@ -1,18 +1,18 @@
$MirBSD: src/bin/ksh/NOTES,v 2.2 2004/12/13 17:33:35 tg Exp $
$MirBSD: src/bin/ksh/NOTES,v 2.3 2004/12/13 18:53:25 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:
- exported aliases and functions (not in ksh93).
- set -t.
- signals/traps not cleared during functions.
- trap DEBUG, local ERR and EXIT traps in functions.
- ERRNO parameter.
- doesn't have posix file globbing (eg, [[:alpha:]], etc.).
- use of an 'agent' to execute unreadable/setuid/setgid shell scripts
(don't ask).
- read/select aren't hooked in to the command line editor
- the last command of a pipeline is not run in the parent shell
- MAIL, MAILPATH, MAILCHECK have been removed in mirbsdksh.
- exported aliases and functions (not in ksh93).
- set -t.
- signals/traps not cleared during functions.
- trap DEBUG, local ERR and EXIT traps in functions.
- ERRNO parameter.
- doesn't have posix file globbing (eg, [[:alpha:]], etc.).
- use of an 'agent' to execute unreadable/setuid/setgid shell scripts
(don't ask).
- read/select aren't hooked in to the command line editor
- the last command of a pipeline is not run in the parent shell
- MAIL, MAILPATH, MAILCHECK have been removed in mirbsdksh.
Known bugs (see also BUG-REPORTS and PROJECTS files):
Variable parsing, Expansion:

24
README
View File

@ -1,13 +1,13 @@
$MirBSD: src/bin/ksh/README,v 2.2 2004/12/13 17:33:35 tg Exp $
$MirBSD: src/bin/ksh/README,v 2.3 2004/12/13 18:53:25 tg Exp $
This is the README for mirbsdksh, developed as part of the MirBSD
operating system at The MirOS Project, and produced portably.
Legal information is provided about a screenpage farther down.
To build on MirOS only, issue 'make obj && make depend && make'.
To build mksh on MirOS, issue 'make obj && make depend && make'.
To build on other systems, consult http://wiki.mirbsd.de/MirbsdKsh
or read Build.sh first.
To build mksh on other operating systems, read Builsd.sh first
or consult http://wiki.mirbsd.de/MirbsdKsh for further infos.
Set the CC, CFLAGS, CPPFLAGS and LDFLAGS environment variables
to your likes. Don't complain if anything doesn't work.
@ -16,8 +16,8 @@ to your likes. Don't complain if anything doesn't work.
LEGAL INFORMATION
This package as a whole is placed under the MirOS licence template
as contained in the "version.c" source code file in this distribu-
tion, by having the project leader asserting a collective copyright.
as contained in the "Build.sh" source file in this distribution,
by having the project leader asserting a collective copyright.
The files alloc.c (Marc Espie), ksh.1tbl and sh.1tbl (University of
California, Berkeley) are provided under a 2-clause or 3-clause BSD
@ -48,11 +48,6 @@ machines. For example, in the CS dept. of MUN, pdksh is installed on a
variety of machines including Suns, HPs, DecStations, pcs running Linux,
etc., and is the login shell of ~5200 users.
Note that pdksh is provided AS IS, with NO WARRANTY, either expressed or
implied. Also note that although the bulk of the code in pdksh is in the
public domain, some files are copyrighted (but freely distributable) and
subject to certain conditions.
If you would like to be notified via email of new releases as they become
available, send mail to pdksh-request@cs.mun.ca with subject
"send release notifications" (or "don't send release notifications" to stop
@ -60,12 +55,7 @@ them).
Newer versions of pdksh may be available from
ftp://ftp.cs.mun.ca:/pub/pdksh/
you may want to check for one if you run into any problems, as the problem may
already be fixed (you can get new release notifications automatically - see
above). The file pdksh-unstable-XXX.tar.gz has the very latest version which
may not compile (it is generated automatically when changes are detected
in the main source repository) - it is for those who want to follow
changes as they are made.
[...]
You can send bug reports, fixes, and enhancements to pdksh@cs.mun.ca (please
don't assume I will see bug reports that are posted to some newsgroup or

25
aclocal.m4 vendored
View File

@ -1,4 +1,4 @@
dnl $MirBSD: src/bin/ksh/aclocal.m4,v 2.1 2004/12/10 18:09:40 tg Exp $
dnl $MirBSD: src/bin/ksh/aclocal.m4,v 2.2 2004/12/13 18:53:25 tg Exp $
dnl-
dnl Copyright (c) 2004
dnl Thorsten "mirabile" Glaser <tg@66h.42h.de>
@ -20,7 +20,7 @@ dnl of this work, even if advised of the possibility of such damage.
dnl-
dnl Based upon code by:
dnl Copyright (C) 1996, Memorial University of Newfoundland.
dnl ------------------------------------------------------------
dnl-
dnl
dnl
dnl Like AC_CHECK_TYPE(), only
@ -48,7 +48,6 @@ $3
])dnl
dnl
dnl
dnl
dnl Check for memmove and if not found, check for bcopy. AC_CHECK_FUNCS()
dnl not used 'cause it confuses some compilers that have memmove/bcopy builtin;
dnl Also want to check if the function deals with overlapping src/dst properly.
@ -114,7 +113,6 @@ AC_DEFUN(KSH_MEMMOVE,
])dnl
dnl
dnl
dnl
dnl Check for sigsetjmp()/siglongjmp() and _setjmp()/_longjmp() pairs.
dnl Can't use simple library check as QNX 422 has _setjmp() but not _longjmp()
dnl (go figure).
@ -135,7 +133,6 @@ AC_DEFUN(KSH_SETJMP,
])dnl
dnl
dnl
dnl
dnl Check for memset function. AC_CHECK_FUNCS() not used 'cause it confuses
dnl some compilers that have memset builtin.
AC_DEFUN(KSH_MEMSET,
@ -158,7 +155,6 @@ AC_DEFUN(KSH_MEMSET,
])dnl
dnl
dnl
dnl
dnl Check for rlim_t in a few places, and if not found, figure out the
dnl size rlim_t should be by looking at struct rlimit.rlim_cur.
AC_DEFUN(KSH_RLIM_CHECK,
@ -193,7 +189,6 @@ AC_DEFUN(KSH_RLIM_CHECK,
])dnl
dnl
dnl
dnl
AC_DEFUN(KSH_DEV_FD,
[AC_CACHE_CHECK(if you have /dev/fd/n, ksh_cv_dev_fd,
[AC_TRY_RUN([
@ -229,7 +224,6 @@ AC_DEFUN(KSH_DEV_FD,
])dnl
dnl
dnl
dnl
dnl Check for sys_siglist[] declaration and existence.
AC_DEFUN(KSH_SYS_SIGLIST,
[AC_DECL_SYS_SIGLIST
@ -250,7 +244,6 @@ AC_DEFUN(KSH_SYS_SIGLIST,
])dnl
dnl
dnl
dnl
dnl Check for sys_errlist[] declaration and existence.
AC_DEFUN(KSH_SYS_ERRLIST,
[AC_CACHE_CHECK(for sys_errlist declaration in errno.h, ksh_cv_decl_sys_errlist,
@ -276,7 +269,6 @@ AC_DEFUN(KSH_SYS_ERRLIST,
])dnl
dnl
dnl
dnl
dnl Check if time() declared in time.h
AC_DEFUN(KSH_TIME_DECLARED,
[AC_CACHE_CHECK(time() declaration in time.h, ksh_cv_time_delcared,
@ -289,7 +281,6 @@ AC_DEFUN(KSH_TIME_DECLARED,
])dnl
dnl
dnl
dnl
dnl Check for working times (ie, it exists and doesn't always return 0).
dnl Defines TIMES_BROKEN if it doesn't exist or if it always returns 0
dnl (also checks for existance of getrusage if times doesn't work).
@ -329,7 +320,6 @@ AC_DEFUN(KSH_TIMES_CHECK,
])dnl
dnl
dnl
dnl
AC_DEFUN(KSH_C_VOID,
[AC_CACHE_CHECK(if compiler understands void, ksh_cv_c_void,
[AC_TRY_COMPILE(
@ -346,7 +336,6 @@ AC_DEFUN(KSH_C_VOID,
])dnl
dnl
dnl
dnl
dnl Early MIPS compilers (used in Ultrix 4.2) don't like
dnl "int x; int *volatile a = &x; *a = 0;"
AC_DEFUN(KSH_C_VOLATILE,
@ -363,7 +352,6 @@ AC_DEFUN(KSH_C_VOLATILE,
])dnl
dnl
dnl
dnl
dnl Check if C compiler understands gcc's __attribute((...)).
dnl checks for noreturn, const, and format(type,fmt,param), also checks
dnl that the compiler doesn't die when it sees an unknown attribute (this
@ -388,7 +376,6 @@ void test_uk() { return; }
])dnl
dnl
dnl
dnl
dnl Check if dup2() does not clear the close on exec flag
AC_DEFUN(KSH_DUP2_CLEXEC_CHECK,
[AC_CACHE_CHECK([if dup2() works (ie, resets the close-on-exec flag)], ksh_cv_dup2_clexec_ok,
@ -428,7 +415,6 @@ main()
])dnl
dnl
dnl
dnl
dnl Check type of signal routines (posix, 4.2bsd, 4.1bsd or v7)
AC_DEFUN(KSH_SIGNAL_CHECK,
[AC_CACHE_CHECK(flavour of signal routines, ksh_cv_signal_check,
@ -565,7 +551,6 @@ AC_DEFUN(KSH_SIGNAL_CHECK,
])dnl
dnl
dnl
dnl
dnl What kind of process groups: POSIX, BSD, SYSV or none
dnl BSD uses setpgrp(pid, pgrp), getpgrp(pid)
dnl POSIX uses setpid(pid, pgrp), getpgrp(void)
@ -668,7 +653,6 @@ AC_DEFUN(KSH_PGRP_CHECK,
])dnl
dnl
dnl
dnl
dnl Check if the pgrp of setpgrp() can't be the pid of a zombie process.
dnl On some systems, the kernel doesn't count zombie processes when checking
dnl if a process group is valid, which can cause problems in creating the
@ -730,7 +714,6 @@ AC_DEFUN(KSH_PGRP_SYNC,
])dnl
dnl
dnl
dnl
dnl Check to see if opendir will open non-directories (not a nice thing)
AC_DEFUN(KSH_OPENDIR_CHECK,
[AC_CACHE_CHECK(if opendir() fails to open non-directories, ksh_cv_opendir_ok,
@ -779,7 +762,6 @@ AC_DEFUN(KSH_OPENDIR_CHECK,
])dnl
dnl
dnl
dnl
dnl Like AC_HAVE_HEADER(unistd.h) but only defines HAVE_UNISTD_H if
dnl the header file is sane (MIPS RISC/os 5.0 (and later?) has a unistd.h
dnl in the bsd43 environ that is incorrect - it defines POSIX_VERSION even
@ -799,7 +781,6 @@ AC_DEFUN(KSH_UNISTD_H,
])dnl
dnl
dnl
dnl
dnl Several OSes need to be detected and symbols defined so the shell can
dnl deal with them. This is a bit kludgy, but...
dnl Currently tests for:
@ -1024,7 +1005,6 @@ README file for work arounds.]))dnl
])dnl
dnl
dnl
dnl
dnl Some systems (eg, SunOS 4.0.3) have <termios.h> and <termio.h> but don't
dnl have the related functions/defines (eg, tcsetattr(), TCSADRAIN, etc.)
dnl or the functions don't work well with tty process groups. Sun's bad
@ -1081,7 +1061,6 @@ dnl fi
])dnl
dnl
dnl
dnl
dnl Check if lstat() is available - special test needed 'cause lstat only
dnl becomes visable if <sys/stat.h> is included (linux 1.3.x)...
AC_DEFUN(KSH_FUNC_LSTAT,

75
chvt.c
View File

@ -1,75 +0,0 @@
/** $MirBSD: src/bin/ksh/chvt.c,v 2.1 2004/12/10 18:09:41 tg 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.
*/
#include "sh.h"
#include <sys/ioctl.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/chvt.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
char *
chvt(char *f)
{
#ifdef HAVE_SETSID
#ifdef TIOCSCTTY
int fd;
if (chown(f, 0, 0))
return "chown";
if (chmod(f, 0600))
return "chmod";
#if defined(HAVE_REVOKE) && !defined(linux)
if (revoke(f))
return "revoke";
#endif
if ((fd = open(f, O_RDWR)) == -1) {
sleep(1);
if ((fd = open(f, O_RDWR)) == -1)
return "open";
}
switch (fork()) {
case -1:
return "fork";
case 0:
break;
default:
_exit(0);
}
if (setsid() == -1)
return "setsid";
if (ioctl(fd, TIOCSCTTY, NULL) == -1)
return "ioctl";
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
if (fd > 2)
close(fd);
return NULL;
#else
return "ioctl - TIOCSCTTY not implemented";
#endif
#else
return "setsid not implemented";
#endif
}

42
main.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/main.c,v 2.2 2004/12/13 16:48:54 tg Exp $ */
/** $MirBSD: src/bin/ksh/main.c,v 2.3 2004/12/13 18:53:25 tg Exp $ */
/* $OpenBSD: main.c,v 1.28 2004/08/23 14:56:32 millert Exp $ */
/*
@ -11,14 +11,42 @@
#include "ksh_stat.h"
#include "ksh_time.h"
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.2 2004/12/13 16:48:54 tg Exp $");
/*
* shell version
*/
extern char **environ;
__RCSID("$MirBSD: src/bin/ksh/main.c,v 2.3 2004/12/13 18:53:25 tg Exp $");
static const char version_param[] =
#ifdef KSH
"KSH_VERSION"
#else /* KSH */
"SH_VERSION"
#endif /* KSH */
;
const char ksh_version[] =
"@(#)PD KSH v5.2.14 MirOS R19 in "
#ifdef MIRBSD_NATIVE
"native "
#endif
#ifdef KSH
"KSH"
#else
"POSIX"
#endif
" mode"
#ifndef MIRBSD_NATIVE
" as mksh"
#endif
;
/*
* global data
*/
extern char **environ;
static void reclaim(void);
static void remove_temps(struct temp *tp);
static int is_restricted(char *name);
@ -31,14 +59,6 @@ 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 *const initcoms [] = {
"typeset", "-x", "SHELL", "PATH", "HOME", NULL,
"typeset", "-r", version_param, NULL,

59
misc.c
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/misc.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/misc.c,v 2.2 2004/12/13 18:53:25 tg Exp $ */
/* $OpenBSD: misc.c,v 1.20 2003/10/22 07:40:38 jmc Exp $ */
/*
@ -10,8 +10,10 @@
#ifdef HAVE_LIMITS_H
# include <limits.h>
#endif
#include <sys/ioctl.h>
#include "ksh_stat.h"
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.1 2004/12/10 18:09:41 tg Exp $");
__RCSID("$MirBSD: src/bin/ksh/misc.c,v 2.2 2004/12/13 18:53:25 tg Exp $");
#ifndef UCHAR_MAX
# define UCHAR_MAX 0xFF
@ -1334,10 +1336,60 @@ ksh_get_wd(char *buf, int bsize)
}
#ifdef KSH
#include "ksh_stat.h"
#if !defined(HAVE_SETSID)
#define NO_CHVT "setsid not implemented"
#elif !defined(TIOCSCTTY)
#define NO_CHVT "no TIOCSCTTY ioctl"
#else
static char *
chvt(char *f)
{
int fd;
if (chown(f, 0, 0))
return "chown";
if (chmod(f, 0600))
return "chmod";
#if defined(HAVE_REVOKE) && !defined(linux)
if (revoke(f))
return "revoke";
#endif
if ((fd = open(f, O_RDWR)) == -1) {
sleep(1);
if ((fd = open(f, O_RDWR)) == -1)
return "open";
}
switch (fork()) {
case -1:
return "fork";
case 0:
break;
default:
_exit(0);
}
if (setsid() == -1)
return "setsid";
if (ioctl(fd, TIOCSCTTY, NULL) == -1)
return "ioctl";
dup2(fd, 0);
dup2(fd, 1);
dup2(fd, 2);
if (fd > 2)
close(fd);
return NULL;
}
#endif
static int
parse_T(char *fn)
{
#ifdef NO_CHVT
warningf(0, "chvt: %s", NO_CHVT);
return -1;
#else
char *rv, dv[20];
struct stat sb;
@ -1361,5 +1413,6 @@ parse_T(char *fn)
return -1;
}
return 0;
#endif
}
#endif

View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/missing.c,v 2.1 2004/12/10 18:09:41 tg Exp $ */
/** $MirBSD: src/bin/ksh/missing.c,v 2.2 2004/12/13 18:53:25 tg Exp $ */
/* $OpenBSD: missing.c,v 1.5 2003/05/16 18:49:46 jsyn Exp $ */
/*
@ -9,6 +9,8 @@
#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 $");
#ifndef HAVE_MEMSET
void *
memset(d, c, n)
@ -289,3 +291,67 @@ dup2(oldd, newd)
return fcntl(oldd, F_DUPFD, newd);
}
#endif /* !HAVE_DUP2 */
/*
* Random functions
*/
#ifndef HAVE_SRANDOM
#undef HAVE_RANDOM
#endif
#ifdef KSH
int rnd_state;
void
rnd_seed(long newval)
{
rnd_put(newval);
rnd_state = 0;
}
long
rnd_get(void)
{
#ifdef HAVE_ARC4RANDOM
if (!rnd_state)
return arc4random() & 0x7FFF;
#endif
#ifdef HAVE_RANDOM
return random() & 0x7FFF;
#else
return rand();
#endif
}
void
rnd_put(long newval)
{
long sv;
rnd_state = 1 | rnd_get();
sv = (rnd_get() << (newval & 7)) ^ newval;
#if defined(HAVE_ARC4RANDOM_PUSH)
arc4random_push(sv);
#elif defined(HAVE_ARC4RANDOM_ADDRANDOM)
arc4random_addrandom((char *)&sv, sizeof(sv));
#endif
#ifdef HAVE_ARC4RANDOM
sv ^= arc4random();
#endif
#ifdef HAVE_RANDOM
srandom(sv);
#else
srand(sv);
#endif
while (rnd_state) {
rnd_get();
rnd_state >>= 1;
}
rnd_state = 1;
}
#endif /* def KSH */

12
proto.h
View File

@ -1,4 +1,4 @@
/** $MirBSD: src/bin/ksh/proto.h,v 2.2 2004/12/13 16:48:54 tg Exp $ */
/** $MirBSD: src/bin/ksh/proto.h,v 2.3 2004/12/13 18:53:25 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 $ */
@ -54,8 +54,6 @@ int c_exec(char **wp);
int c_builtin(char **wp);
/* c_test.c */
int c_test(char **wp);
/* chvt.c */
char * chvt(char *);
/* edit.c: most prototypes in edit.h */
void x_init(void);
int x_read(char *buf, size_t len);
@ -205,16 +203,16 @@ char *str_zcpy(char *dst, const char *src, int dsize);
int blocking_read(int fd, char *buf, int nbytes);
int reset_nonblock(int fd);
char *ksh_get_wd(char *buf, int bsize);
/* missing.c */
long rnd_get(void);
void rnd_put(long);
void rnd_seed(long);
/* path.c */
int make_path(const char *cwd, const char *file,
char **pathlist, XString *xsp, int *phys_pathp);
void simplify_path(char *path);
char *get_phys_path(const char *path);
void set_current_wd(char *path);
/* rnd.c */
long rnd_get(void);
void rnd_put(long);
void rnd_seed(long);
/* syn.c */
void initkeywords(void);
struct op * compile(Source *s);

86
rnd.c
View File

@ -1,86 +0,0 @@
/** $MirBSD: src/bin/ksh/rnd.c,v 2.1 2004/12/10 18:09:42 tg 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.
*/
#include "sh.h"
#include "proto.h"
__RCSID("$MirBSD: src/bin/ksh/rnd.c,v 2.1 2004/12/10 18:09:42 tg Exp $");
#ifndef HAVE_SRANDOM
#undef HAVE_RANDOM
#endif
#ifdef KSH
int rnd_state;
void
rnd_seed(long newval)
{
rnd_put(newval);
rnd_state = 0;
}
long
rnd_get(void)
{
#ifdef HAVE_ARC4RANDOM
if (!rnd_state)
return arc4random() & 0x7FFF;
#endif
#ifdef HAVE_RANDOM
return random() & 0x7FFF;
#else
return rand();
#endif
}
void
rnd_put(long newval)
{
long sv;
rnd_state = 1 | rnd_get();
sv = (rnd_get() << (newval & 7)) ^ newval;
#if defined(HAVE_ARC4RANDOM_PUSH)
arc4random_push(sv);
#elif defined(HAVE_ARC4RANDOM_ADDRANDOM)
arc4random_addrandom((char *)&sv, sizeof(sv));
#endif
#ifdef HAVE_ARC4RANDOM
sv ^= arc4random();
#endif
#ifdef HAVE_RANDOM
srandom(sv);
#else
srand(sv);
#endif
while (rnd_state) {
rnd_get();
rnd_state >>= 1;
}
rnd_state = 1;
}
#endif /* def KSH */

View File

@ -1,42 +0,0 @@
/** $MirBSD: src/bin/ksh/version.c,v 2.1 2004/12/10 18:09:42 tg Exp $ */
/* $OpenBSD: version.c,v 1.12 1999/07/14 13:37: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.
*-
* value of $KSH_VERSION (or $SH_VERSION)
*/
#include "sh.h"
const char ksh_version[] =
"@(#)PD KSH v5.2.14 MirOS R19 in "
#ifdef MIRBSD_NATIVE
"native "
#endif
#ifdef KSH
"KSH"
#else
"POSIX"
#endif
" mode"
#ifdef MKSH
" as mksh"
#endif
;