From e2f55255d00b23da2902fabd8fe5f1af32c9c421 Mon Sep 17 00:00:00 2001 From: Theo de Raadt Date: Tue, 1 Aug 2017 14:30:08 +0000 Subject: Disable ksh VI-editing mode on the install media. We need the space savings. --- bin/ksh/Makefile | 4 ++-- bin/ksh/config.h | 15 +-------------- bin/ksh/history.c | 18 +++++++++++++----- 3 files changed, 16 insertions(+), 21 deletions(-) (limited to 'bin') diff --git a/bin/ksh/Makefile b/bin/ksh/Makefile index 89bab587ee5..0e356cf1337 100644 --- a/bin/ksh/Makefile +++ b/bin/ksh/Makefile @@ -1,4 +1,4 @@ -# $OpenBSD: Makefile,v 1.33 2016/03/30 06:38:40 jmc Exp $ +# $OpenBSD: Makefile,v 1.34 2017/08/01 14:30:05 deraadt Exp $ PROG= ksh SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \ @@ -6,7 +6,7 @@ SRCS= alloc.c c_ksh.c c_sh.c c_test.c c_ulimit.c edit.c emacs.c eval.c \ misc.c path.c shf.c syn.c table.c trap.c tree.c tty.c var.c \ version.c vi.c -DEFS= -Wall +DEFS= -Wall -DEMACS -DVI CFLAGS+=${DEFS} -I. -I${.CURDIR} -I${.CURDIR}/../../lib/libc/gen MAN= ksh.1 sh.1 diff --git a/bin/ksh/config.h b/bin/ksh/config.h index 8feecb3a552..abf6b6374a7 100644 --- a/bin/ksh/config.h +++ b/bin/ksh/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.15 2015/09/14 16:10:55 nicm Exp $ */ +/* $OpenBSD: config.h,v 1.16 2017/08/01 14:30:05 deraadt Exp $ */ /* config.h. NOT generated automatically. */ @@ -11,12 +11,6 @@ #ifndef CONFIG_H #define CONFIG_H -/* Include emacs editing? */ -#define EMACS 1 - -/* Include vi editing? */ -#define VI 1 - /* Include job control? */ #define JOBS 1 @@ -42,13 +36,6 @@ # undef EDIT #endif -/* Super small configuration-- no editing. */ -#if defined(EDIT) && defined(NOEDIT) -# undef EDIT -# undef EMACS -# undef VI -#endif - /* Editing implies history */ #if defined(EDIT) && !defined(HISTORY) # define HISTORY diff --git a/bin/ksh/history.c b/bin/ksh/history.c index 14e0c4a29a9..f3a6daa9c33 100644 --- a/bin/ksh/history.c +++ b/bin/ksh/history.c @@ -1,4 +1,4 @@ -/* $OpenBSD: history.c,v 1.62 2017/07/24 23:56:37 tb Exp $ */ +/* $OpenBSD: history.c,v 1.63 2017/08/01 14:30:05 deraadt Exp $ */ /* * command history @@ -593,10 +593,12 @@ history_lock(int operation) void histsave(int lno, const char *cmd, int dowrite) { - struct stat sb; - char *c, *cp, *encoded; + char *c, *cp; if (dowrite && histfh) { +#ifndef SMALL + struct stat sb; + history_lock(LOCK_EX); if (fstat(fileno(histfh), &sb) != -1) { if (timespeccmp(&sb.st_mtim, &last_sb.st_mtim, ==)) @@ -608,6 +610,7 @@ histsave(int lno, const char *cmd, int dowrite) history_load(hist_source); } } +#endif } c = str_save(cmd, APERM); @@ -624,6 +627,9 @@ histsave(int lno, const char *cmd, int dowrite) *histptr = c; if (dowrite && histfh) { +#ifndef SMALL + char *encoded; + /* append to file */ if (fseeko(histfh, 0, SEEK_END) == 0 && stravis(&encoded, c, VIS_SAFE | VIS_NL) != -1) { @@ -635,14 +641,16 @@ histsave(int lno, const char *cmd, int dowrite) free(encoded); } history_lock(LOCK_UN); +#endif } } static FILE * history_open(void) { + FILE *f = NULL; +#ifndef SMALL struct stat sb; - FILE *f; int fd, fddup; if ((fd = open(hname, O_RDWR | O_CREAT | O_EXLOCK, 0600)) == -1) @@ -659,7 +667,7 @@ history_open(void) close(fddup); else last_sb = sb; - +#endif return f; } -- cgit v1.2.3