avoid MAIL* environment variables to save a few bytes in install media
authorkn <kn@openbsd.org>
Sun, 23 Jul 2023 23:42:03 +0000 (23:42 +0000)
committerkn <kn@openbsd.org>
Sun, 23 Jul 2023 23:42:03 +0000 (23:42 +0000)
ksh(1) MAIL, MAILCHECK, MAILPATH mbox handling is useless in the installer.

OK miod deraadt

bin/ksh/main.c
bin/ksh/var.c
distrib/special/ksh/Makefile

index 5ab581e..b011b22 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: main.c,v 1.99 2023/02/08 17:22:10 kn Exp $    */
+/*     $OpenBSD: main.c,v 1.100 2023/07/23 23:42:03 kn Exp $   */
 
 /*
  * startup, main loop, environments and error handling
@@ -87,7 +87,11 @@ static const char *initcoms [] = {
        "typeset", "-x", "SHELL", "PATH", "HOME", "PWD", "OLDPWD", NULL,
        "typeset", "-ir", "PPID", NULL,
        "typeset", "-i", "OPTIND=1", NULL,
+#ifndef SMALL
        "eval", "typeset -i RANDOM MAILCHECK=\"${MAILCHECK-600}\" SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
+#else
+       "eval", "typeset -i RANDOM SECONDS=\"${SECONDS-0}\" TMOUT=\"${TMOUT-0}\"", NULL,
+#endif /* SMALL */
        "alias",
         /* Standard ksh aliases */
          "hash=alias -t",      /* not "alias -t --": hash -r needs to work */
@@ -615,7 +619,9 @@ shell(Source *volatile s, volatile int toplevel)
                if (interactive) {
                        got_sigwinch = 1;
                        j_notify();
+#ifndef SMALL
                        mcheck();
+#endif /* SMALL */
                        set_prompt(PS1);
                }
 
index 9dbba07..0757440 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: var.c,v 1.72 2021/03/05 15:22:03 zhuk Exp $   */
+/*     $OpenBSD: var.c,v 1.73 2023/07/23 23:42:03 kn Exp $     */
 
 #include <sys/stat.h>
 #include <sys/time.h>
@@ -108,9 +108,11 @@ initvar(void)
                { "HISTSIZE",           V_HISTSIZE },
                { "EDITOR",             V_EDITOR },
                { "VISUAL",             V_VISUAL },
+#ifndef SMALL
                { "MAIL",               V_MAIL },
                { "MAILCHECK",          V_MAILCHECK },
                { "MAILPATH",           V_MAILPATH },
+#endif /* SMALL */
                { "RANDOM",             V_RANDOM },
                { "SECONDS",            V_SECONDS },
                { "TMOUT",              V_TMOUT },
@@ -1029,6 +1031,7 @@ setspec(struct tbl *vp)
                                x_cols = l;
                }
                break;
+#ifndef SMALL
        case V_MAIL:
                mbset(str_val(vp));
                break;
@@ -1040,6 +1043,7 @@ setspec(struct tbl *vp)
                mcset(intval(vp));
                vp->flag |= SPECIAL;
                break;
+#endif /* SMALL */
        case V_RANDOM:
                vp->flag &= ~SPECIAL;
                srand_deterministic((unsigned int)intval(vp));
@@ -1099,17 +1103,21 @@ unsetspec(struct tbl *vp)
                afree(tmpdir, APERM);
                tmpdir = NULL;
                break;
+#ifndef SMALL
        case V_MAIL:
                mbset(NULL);
                break;
        case V_MAILPATH:
                mpset(NULL);
                break;
+#endif /* SMALL */
        case V_HISTCONTROL:
                sethistcontrol(NULL);
                break;
        case V_LINENO:
+#ifndef SMALL
        case V_MAILCHECK:       /* at&t ksh leaves previous value in place */
+#endif /* SMALL */
        case V_RANDOM:
        case V_SECONDS:
        case V_TMOUT:           /* at&t ksh leaves previous value in place */
index 9aced4e..c4b76db 100644 (file)
@@ -1,8 +1,8 @@
-#      $OpenBSD: Makefile,v 1.6 2023/02/08 17:22:10 kn Exp $
+#      $OpenBSD: Makefile,v 1.7 2023/07/23 23:42:03 kn Exp $
 
 PROG=  ksh
 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 mail.c main.c \
+       exec.c expr.c history.c io.c jobs.c lex.c main.c \
        misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \
        vi.c