diff --git a/Build.sh b/Build.sh index e66ec76..f599bd7 100644 --- a/Build.sh +++ b/Build.sh @@ -1,5 +1,5 @@ #!/bin/sh -# $MirBSD: Build.sh,v 1.13 2004/10/28 16:35:01 tg Exp $ +# $MirBSD: Build.sh,v 1.14 2004/11/10 17:13:10 tg Exp $ #- # Copyright (c) 2004 # Thorsten "mirabile" Glaser @@ -63,9 +63,12 @@ if test -e strlfun.c; then test -s $man || man=mksh.1 test -s $man || man=ksh.1tbl cp ksh.unstripped mksh - strip -R .note -R .comment --strip-unneeded --strip-all mksh \ - || strip mksh || mv ksh.unstripped mksh - size $BINARY + strip -R .comment --strip-unneeded --strip-all mksh || rm mksh + if ! test -e mksh; then + cp ksh.unstripped mksh + strip mksh || mv ksh.unstripped mksh + fi + size mksh echo "done." echo "" echo "If you want to test mirbsdksh:" diff --git a/Makefile b/Makefile index 57684a2..ebd041f 100644 --- a/Makefile +++ b/Makefile @@ -1,9 +1,9 @@ -# $MirBSD: Makefile,v 1.9 2004/10/31 22:28:41 tg Exp $ +# $MirBSD: Makefile,v 1.10 2004/11/10 17:13:10 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 mail.c \ +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 MAN= ksh.1tbl sh.1tbl diff --git a/NOTES b/NOTES index 6612bd4..e205f63 100644 --- a/NOTES +++ b/NOTES @@ -1,4 +1,4 @@ -$MirBSD: NOTES,v 1.2 2004/04/17 00:47:16 tg Stab $ +$MirBSD: NOTES,v 1.3 2004/11/10 17:13:10 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: @@ -12,6 +12,7 @@ General features of at&t ksh88 that are not (yet) in pdksh: (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: diff --git a/PROJECTS b/PROJECTS index 901b700..78634c6 100644 --- a/PROJECTS +++ b/PROJECTS @@ -1,4 +1,4 @@ -$MirBSD: PROJECTS,v 1.4 2004/11/01 12:17:47 tg Exp $ +$MirBSD: PROJECTS,v 1.5 2004/11/10 17:13:10 tg Exp $ $OpenBSD: PROJECTS,v 1.5 1999/07/14 13:37:23 millert Exp $ @@ -33,16 +33,6 @@ Things to be done in pdksh (see also the NOTES file): should be written to be used in regression testing. The tests directory contains some tests, but many more need to be written. - * internationalization - Need to handle with the LANG and LC_* environment variables. This - involves changes to ensure macros are being used (currently - uses its own macros in many places), figuring out how to deal with - bases (for integer arithmetic, eg, 12#1A), and (the nasty one) doing - string look ups for error messages, etc.. It probably isn't worth - translating strings to other languages yet as the code is likely - to change a lot in the near future, but it would be good to have the - code set up so string tables can be used. - * trap code * add the DEBUG trap. * fix up signal handling code. In particular, fatal vs tty signals, @@ -92,11 +82,7 @@ Things to be done in pdksh (see also the NOTES file): * documentation Some sort of tutorial with examples would be good. Texinfo is probably - the best medium for this. Also, the man page could be converted to - texinfo (if the tutorial and man page are put in the same texinfo - page, they should be somewhat distinct - i.e., the tutorial should - be a separate thread - but there should be cross references between the - two). + the best medium for this. * miscellaneous * POSIX specifies what happens when various kinds of errors occur diff --git a/ksh.1tbl b/ksh.1tbl index c9dc896..dc028f2 100644 --- a/ksh.1tbl +++ b/ksh.1tbl @@ -1,4 +1,4 @@ -.\" $MirBSD: ksh.1tbl,v 1.39 2004/11/10 17:01:11 tg Exp $ +.\" $MirBSD: ksh.1tbl,v 1.40 2004/11/10 17:13:10 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 $ .\" @@ -1384,12 +1384,6 @@ When an external command is executed by the shell, this parameter is set in the environment of the new process to the path of the executed command. In interactive use, this parameter is also set in the parent shell to the last word of the previous command. -When -.Ev MAILPATH -messages are evaluated, this parameter contains the name of the file that -changed (see -.Ev MAILPATH -parameter below). .It Ev CDPATH Search path for the .Ic cd @@ -1519,31 +1513,6 @@ executed. .It Ev LINES Set to the number of lines on the terminal or window. Not yet implemented. -.It Ev MAIL -If set, the user will be informed of the arrival of mail in the named file. -This parameter is ignored if the -.Ev MAILPATH -parameter is set. -.It Ev MAILCHECK -How often, in seconds, the shell will check for mail in the file(s) specified -by -.Ev MAIL -or -.Ev MAILPATH . -If set to 0, the shell checks before each prompt. -The default is 600 (10 minutes). -.It Ev MAILPATH -A list of files to be checked for mail. -The list is colon separated, and each file may be followed by a -.Ql \&? -and a message to be printed if new mail has arrived. -Command, parameter and -arithmetic substitution is performed on the message, and, during substitution, -the parameter -.Ev $_ -contains the name of the file. -The default message is -.Dq you have mail in $_ . .It Ev OLDPWD The previous working directory. Unset if diff --git a/mail.c b/mail.c deleted file mode 100644 index 31d2fa9..0000000 --- a/mail.c +++ /dev/null @@ -1,201 +0,0 @@ -/** $MirBSD: mail.c,v 1.6 2004/10/28 11:53:42 tg Exp $ */ -/* $OpenBSD: mail.c,v 1.9 1999/06/15 01:18:35 millert Exp $ */ - -/* - * Mailbox checking code by Robert J. Gibson, adapted for PD ksh by - * John R. MacMillan - */ - -#include "config.h" - -#ifdef KSH -#include "sh.h" -#include "ksh_stat.h" -#include "ksh_time.h" - -__RCSID("$MirBSD: mail.c,v 1.6 2004/10/28 11:53:42 tg Exp $"); - -#define MBMESSAGE "you have mail in $_" - -typedef struct mbox { - struct mbox *mb_next; /* next mbox in list */ - char *mb_path; /* path to mail file */ - char *mb_msg; /* to announce arrival of new mail */ - time_t mb_mtime; /* mtime of mail file */ -} mbox_t; - -/* - * $MAILPATH is a linked list of mboxes. $MAIL is a treated as a - * special case of $MAILPATH, where the list has only one node. The - * same list is used for both since they are exclusive. - */ - -static mbox_t *mplist; -static mbox_t mbox; -static time_t mlastchkd; /* when mail was last checked */ -static time_t mailcheck_interval; - -static void munset(mbox_t *mlist); /* free mlist and mval */ -static mbox_t * mballoc(char *p, char *m); /* allocate a new mbox */ -static void mprintit(mbox_t *mbp); - -void -mcheck(void) -{ - mbox_t *mbp; - time_t now; - struct tbl *vp; - struct stat stbuf; - - now = time(NULL); - if (mlastchkd == 0) - mlastchkd = now; - if (now - mlastchkd >= mailcheck_interval) { - mlastchkd = now; - - if (mplist) - mbp = mplist; - else if ((vp = global("MAIL")) && (vp->flag & ISSET)) - mbp = &mbox; - else - mbp = NULL; - - while (mbp) { - if (mbp->mb_path && stat(mbp->mb_path, &stbuf) == 0 - && S_ISREG(stbuf.st_mode)) - { - if (stbuf.st_size - && mbp->mb_mtime != stbuf.st_mtime - && stbuf.st_atime <= stbuf.st_mtime) - mprintit(mbp); - mbp->mb_mtime = stbuf.st_mtime; - } else { - /* - * Some mail readers remove the mail - * file if all mail is read. If file - * does not exist, assume this is the - * case and set mtime to zero. - */ - mbp->mb_mtime = 0; - } - mbp = mbp->mb_next; - } - } -} - -void -mcset(long int interval) -{ - mailcheck_interval = interval; -} - -void -mbset(char *p) -{ - struct stat stbuf; - - if (mbox.mb_msg) - afree((void *)mbox.mb_msg, APERM); - if (mbox.mb_path) - afree((void *)mbox.mb_path, APERM); - /* Save a copy to protect from export (which munges the string) */ - mbox.mb_path = str_save(p, APERM); - mbox.mb_msg = NULL; - if (p && stat(p, &stbuf) == 0 && S_ISREG(stbuf.st_mode)) - mbox.mb_mtime = stbuf.st_mtime; - else - mbox.mb_mtime = 0; -} - -void -mpset(char *mptoparse) -{ - mbox_t *mbp; - char *mpath, *mmsg, *mval; - char *p; - - munset( mplist ); - mplist = NULL; - mval = str_save(mptoparse, APERM); - while (mval) { - mpath = mval; - if ((mval = strchr(mval, PATHSEP)) != NULL) { - *mval = '\0', mval++; - } - /* POSIX/bourne-shell say file%message */ - for (p = mpath; (mmsg = strchr(p, '%')); ) { - /* a literal percent? (POSIXism) */ - if (mmsg[-1] == '\\') { - /* use memmove() to avoid overlap problems */ - memmove(mmsg - 1, mmsg, strlen(mmsg) + 1); - p = mmsg + 1; - continue; - } - break; - } - /* at&t ksh says file?message */ - if (!mmsg && !Flag(FPOSIX)) - mmsg = strchr(mpath, '?'); - if (mmsg) { - *mmsg = '\0'; - mmsg++; - } - mbp = mballoc(mpath, mmsg); - mbp->mb_next = mplist; - mplist = mbp; - } -} - -static void -munset(mbox_t *mlist) -{ - mbox_t *mbp; - - while (mlist != NULL) { - mbp = mlist; - mlist = mbp->mb_next; - if (!mlist) - afree((void *)mbp->mb_path, APERM); - afree((void *)mbp, APERM); - } -} - -static mbox_t * -mballoc(char *p, char *m) -{ - struct stat stbuf; - mbox_t *mbp; - - mbp = (mbox_t *)alloc(sizeof(mbox_t), APERM); - mbp->mb_next = NULL; - mbp->mb_path = p; - mbp->mb_msg = m; - if (stat(mbp->mb_path, &stbuf) == 0 && S_ISREG(stbuf.st_mode)) - mbp->mb_mtime = stbuf.st_mtime; - else - mbp->mb_mtime = 0; - return(mbp); -} - -static void -mprintit(mbox_t *mbp) -{ - struct tbl *vp; - -#if 0 - /* - * I doubt this $_ overloading is bad in /bin/sh mode. Anyhow, we - * crash as the code looks now if we do not set vp. Now, this is - * easy to fix too, but I'd like to see what POSIX says before doing - * a change like that. - */ - if (!Flag(FSH)) -#endif - /* Ignore setstr errors here (arbitrary) */ - setstr((vp = local("_", FALSE)), mbp->mb_path, KSH_RETURN_ERROR); - - shellf("%s\n", substitute(mbp->mb_msg ? mbp->mb_msg : MBMESSAGE, 0)); - - unset(vp, 0); -} -#endif /* KSH */ diff --git a/main.c b/main.c index 0cbfdb0..8dd0cef 100644 --- a/main.c +++ b/main.c @@ -1,4 +1,4 @@ -/** $MirBSD: main.c,v 1.14 2004/10/31 23:02:05 tg Exp $ */ +/** $MirBSD: main.c,v 1.15 2004/11/10 17:13:11 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.14 2004/10/31 23:02:05 tg Exp $"); +__RCSID("$MirBSD: main.c,v 1.15 2004/11/10 17:13:11 tg Exp $"); extern char **environ; @@ -45,7 +45,7 @@ static const char *const initcoms [] = { "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, + "eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL, #endif /* KSH */ "alias", /* Standard ksh aliases */ @@ -606,9 +606,6 @@ shell(Source *volatile s, volatile int toplevel) if (interactive) { j_notify(); -#ifdef KSH - mcheck(); -#endif /* KSH */ set_prompt(PS1, s); } diff --git a/proto.h b/proto.h index 8fddc0b..1680979 100644 --- a/proto.h +++ b/proto.h @@ -1,4 +1,4 @@ -/** $MirBSD: proto.h,v 1.9 2004/10/31 22:28:43 tg Exp $ */ +/** $MirBSD: proto.h,v 1.10 2004/11/10 17:13:11 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 $ */ @@ -164,13 +164,6 @@ void yyerror(const char *fmt, ...) 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); diff --git a/table.h b/table.h index 9042930..b54f47f 100644 --- a/table.h +++ b/table.h @@ -1,4 +1,4 @@ -/** $MirBSD: table.h,v 1.5 2004/10/28 11:53:43 tg Exp $ */ +/** $MirBSD: table.h,v 1.6 2004/11/10 17:13:11 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 $ */ @@ -156,9 +156,6 @@ extern const struct builtin shbuiltins [], kshbuiltins []; #define V_IFS 2 #define V_SECONDS 3 #define V_OPTIND 4 -#define V_MAIL 5 -#define V_MAILPATH 6 -#define V_MAILCHECK 7 #define V_RANDOM 8 #define V_HISTSIZE 9 #define V_HISTFILE 10 diff --git a/var.c b/var.c index 4ebd0bc..e7c1d40 100644 --- a/var.c +++ b/var.c @@ -1,4 +1,4 @@ -/** $MirBSD: var.c,v 1.11 2004/10/28 11:53:44 tg Exp $ */ +/** $MirBSD: var.c,v 1.12 2004/11/10 17:13:11 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 -__RCSID("$MirBSD: var.c,v 1.11 2004/10/28 11:53:44 tg Exp $"); +__RCSID("$MirBSD: var.c,v 1.12 2004/11/10 17:13:11 tg Exp $"); /* * Variables @@ -103,9 +103,6 @@ initvar(void) { "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 }, @@ -999,17 +996,6 @@ setspec(struct tbl *vp) break; #endif /* EDIT */ #ifdef KSH - case V_MAIL: - mbset(str_val(vp)); - break; - case V_MAILPATH: - mpset(str_val(vp)); - break; - case V_MAILCHECK: - vp->flag &= ~SPECIAL; - mcset(intval(vp)); - vp->flag |= SPECIAL; - break; case V_RANDOM: vp->flag &= ~SPECIAL; rnd_put(intval(vp)); @@ -1056,18 +1042,8 @@ unsetspec(struct tbl *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 */ @@ -1079,7 +1055,7 @@ unsetspec(struct tbl *vp) * but OPTARG does not (still set by getopts) and _ is also still * set in various places. * Don't know what at&t does for: - * MAIL, MAILPATH, HISTSIZE, HISTFILE, + * HISTSIZE, HISTFILE, * Unsetting these in at&t ksh does not loose the 'specialness': * no effect: IFS, COLUMNS, PATH, TMPDIR, * VISUAL, EDITOR,