oksh-noxz

[fork] Portable OpenBSD ksh, based on the Public Domain Korn Shell (pdksh).
git clone https://noxz.tech/git/oksh-noxz.git
oksh-noxz

commit: 94493b305c8c1b5736174082c4b1ca72978e349b
parent: e30f4d775d16e6537ad0371becb6a0176bff06cc
author: Brian Callahan <bcallah@openbsd.org>
date:   Mon, 15 Jan 2018 21:25:36 -0500
Update to latest code.
Add Makefile and README to .gitignore
M.gitignore2+
MCVS/Entries90++++++++++----------
Mc_ksh.c4+-
Mconfig.h19+----
Medit.c4+-
Memacs.c4+-
Meval.c15+---
Mexec.c4+-
Mhistory.c31+------
Mlex.c18++--
Mlex.h7+-
Mmain.c18++--
Mmisc.c27+++---
Msh.h14+--
Mvar.c14+--
15 files changed, 87 insertions(+), 184 deletions(-)
diff --git a/.gitignore b/.gitignore
@@ -1,2 +1,4 @@
 oksh
+Makefile
+README
 *.o
diff --git a/CVS/Entries b/CVS/Entries
@@ -1,46 +1,46 @@
-/config.h/1.17/Result of merge//
-/history.c/1.78/Result of merge//
-/main.c/1.86/Result of merge//
-/emacs.c/1.82/Result of merge//
-/CONTRIBUTORS/1.10/Fri Jan 12 20:53:58 2018//
-/LEGAL/1.2/Fri Jan 12 20:53:58 2018//
-/NOTES/1.16/Fri Jan 12 20:54:17 2018//
-/PROJECTS/1.9/Fri Jan 12 20:53:58 2018//
-/alloc.c/1.18/Fri Jan 12 20:53:58 2018//
-/c_ksh.c/1.56/Fri Jan 12 20:53:58 2018//
-/c_sh.c/1.62/Fri Jan 12 20:53:58 2018//
-/c_test.c/1.24/Fri Jan 12 20:53:58 2018//
-/c_test.h/1.4/Fri Jan 12 20:53:58 2018//
-/c_ulimit.c/1.24/Fri Jan 12 20:53:58 2018//
-/edit.c/1.61/Fri Jan 12 20:53:58 2018//
-/edit.h/1.11/Fri Jan 12 20:53:58 2018//
-/eval.c/1.57/Fri Jan 12 20:53:58 2018//
-/exec.c/1.70/Fri Jan 12 20:53:58 2018//
-/expand.h/1.15/Fri Jan 12 20:53:58 2018//
-/expr.c/1.32/Fri Jan 12 20:53:58 2018//
-/io.c/1.35/Fri Jan 12 20:53:58 2018//
-/jobs.c/1.58/Fri Jan 12 20:53:58 2018//
-/ksh.1/1.197/Fri Jan 12 20:53:58 2018//
-/lex.c/1.77/Fri Jan 12 20:53:58 2018//
-/lex.h/1.20/Fri Jan 12 20:53:58 2018//
-/mail.c/1.22/Fri Jan 12 20:53:58 2018//
-/misc.c/1.65/Fri Jan 12 20:53:58 2018//
-/path.c/1.22/Fri Jan 12 20:53:58 2018//
-/sh.1/1.146/Fri Jan 12 20:53:58 2018//
-/sh.h/1.68/Fri Jan 12 20:53:58 2018//
-/shf.c/1.31/Fri Jan 12 20:53:58 2018//
-/shf.h/1.8/Fri Jan 12 20:53:58 2018//
-/syn.c/1.38/Fri Jan 12 20:53:58 2018//
-/table.c/1.24/Fri Jan 12 20:53:58 2018//
-/table.h/1.13/Fri Jan 12 20:53:58 2018//
-/trap.c/1.30/Fri Jan 12 20:53:58 2018//
-/tree.c/1.30/Fri Jan 12 20:53:58 2018//
-/tree.h/1.12/Fri Jan 12 20:53:58 2018//
-/tty.c/1.16/Fri Jan 12 20:53:58 2018//
-/tty.h/1.6/Fri Jan 12 20:53:58 2018//
-/var.c/1.63/Fri Jan 12 20:53:58 2018//
-/version.c/1.12/Fri Jan 12 20:53:58 2018//
-/Makefile/1.38/Sat Jan 13 03:28:07 2018//
-/README/1.16/Sat Jan 13 03:28:07 2018//
-/vi.c/1.54/Sat Jan 13 03:28:07 2018//
+/CONTRIBUTORS/1.10/Tue Jan 16 02:19:52 2018//
+/LEGAL/1.2/Tue Jan 16 02:19:52 2018//
+/NOTES/1.16/Tue Jan 16 02:19:52 2018//
+/PROJECTS/1.9/Tue Jan 16 02:19:52 2018//
+/alloc.c/1.18/Tue Jan 16 02:19:52 2018//
+/c_ksh.c/1.57/Tue Jan 16 02:20:22 2018//
+/c_sh.c/1.62/Tue Jan 16 02:19:52 2018//
+/c_test.c/1.24/Tue Jan 16 02:19:52 2018//
+/c_test.h/1.4/Tue Jan 16 02:19:52 2018//
+/c_ulimit.c/1.24/Tue Jan 16 02:19:52 2018//
+/edit.c/1.62/Tue Jan 16 02:20:22 2018//
+/edit.h/1.11/Tue Jan 16 02:19:52 2018//
+/emacs.c/1.83/Result of merge//
+/eval.c/1.58/Tue Jan 16 02:20:22 2018//
+/exec.c/1.71/Tue Jan 16 02:20:22 2018//
+/expand.h/1.15/Tue Jan 16 02:19:52 2018//
+/expr.c/1.32/Tue Jan 16 02:19:52 2018//
+/io.c/1.35/Tue Jan 16 02:19:52 2018//
+/jobs.c/1.58/Tue Jan 16 02:19:52 2018//
+/ksh.1/1.197/Tue Jan 16 02:19:52 2018//
+/lex.c/1.78/Tue Jan 16 02:20:22 2018//
+/lex.h/1.21/Tue Jan 16 02:20:22 2018//
+/mail.c/1.22/Tue Jan 16 02:19:52 2018//
+/main.c/1.88/Result of merge//
+/misc.c/1.67/Tue Jan 16 02:20:22 2018//
+/path.c/1.22/Tue Jan 16 02:19:52 2018//
+/sh.1/1.146/Tue Jan 16 02:19:52 2018//
+/sh.h/1.70/Tue Jan 16 02:20:22 2018//
+/shf.c/1.31/Tue Jan 16 02:19:52 2018//
+/shf.h/1.8/Tue Jan 16 02:19:52 2018//
+/syn.c/1.38/Tue Jan 16 02:19:52 2018//
+/table.c/1.24/Tue Jan 16 02:19:52 2018//
+/table.h/1.13/Tue Jan 16 02:19:52 2018//
+/trap.c/1.30/Tue Jan 16 02:19:52 2018//
+/tree.c/1.30/Tue Jan 16 02:19:52 2018//
+/tree.h/1.12/Tue Jan 16 02:19:52 2018//
+/tty.c/1.16/Tue Jan 16 02:19:52 2018//
+/tty.h/1.6/Tue Jan 16 02:19:52 2018//
+/var.c/1.64/Tue Jan 16 02:20:22 2018//
+/version.c/1.12/Tue Jan 16 02:19:52 2018//
+/vi.c/1.54/Tue Jan 16 02:19:52 2018//
+/Makefile/1.38/Tue Jan 16 02:21:56 2018//
+/README/1.16/Tue Jan 16 02:21:56 2018//
+/config.h/1.19/Tue Jan 16 02:21:56 2018//
+/history.c/1.80/Tue Jan 16 02:21:56 2018//
 D
diff --git a/c_ksh.c b/c_ksh.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: c_ksh.c,v 1.56 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: c_ksh.c,v 1.57 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * built-in Korn commands: c_*
@@ -1384,9 +1384,7 @@ const struct builtin kshbuiltins [] = {
 	{"+command", c_command},
 	{"echo", c_print},
 	{"*=export", c_typeset},
-#ifdef HISTORY
 	{"+fc", c_fc},
-#endif /* HISTORY */
 	{"+getopts", c_getopts},
 	{"+jobs", c_jobs},
 	{"+kill", c_kill},
diff --git a/config.h b/config.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: config.h,v 1.17 2018/01/05 15:44:31 jca Exp $	*/
+/*	$OpenBSD: config.h,v 1.19 2018/01/15 14:58:05 jca Exp $	*/
 
 /* config.h.  NOT generated automatically. */
 
@@ -11,12 +11,6 @@
 #ifndef CONFIG_H
 #define CONFIG_H
 
-/* Include brace-expansion? */
-#define BRACE_EXPAND 1
-
-/* Include any history? */
-#define HISTORY 1
-
 /* Strict POSIX behaviour? */
 /* #undef POSIXLY_CORRECT */
 
@@ -27,17 +21,10 @@
  * End of configuration stuff for PD ksh.
  */
 
-#if defined(EMACS) || defined(VI)
-# define	EDIT
-#else
-# undef		EDIT
+#if !defined(EMACS) && !defined(VI)
+# error "Define either EMACS or VI."
 #endif
 
-/* Editing implies history */
-#if defined(EDIT) && !defined(HISTORY)
-# define HISTORY
-#endif /* EDIT */
-
 #include "portable.h"
 
 #endif /* CONFIG_H */
diff --git a/edit.c b/edit.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: edit.c,v 1.61 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: edit.c,v 1.62 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * Command line editing - common code
@@ -6,7 +6,6 @@
  */
 
 #include "config.h"
-#ifdef EDIT
 
 #include <sys/ioctl.h>
 #include <sys/stat.h>
@@ -910,4 +909,3 @@ x_escape(const char *s, size_t len, int (*putbuf_func) (const char *, size_t))
 
 	return (rval);
 }
-#endif /* EDIT */
diff --git a/emacs.c b/emacs.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: emacs.c,v 1.82 2018/01/08 13:01:31 millert Exp $	*/
+/*	$OpenBSD: emacs.c,v 1.83 2018/01/14 16:04:21 anton Exp $	*/
 
 /*
  *  Emacs-like command line editing and history
@@ -2134,4 +2134,4 @@ x_lastcp(void)
 	return (xlp);
 }
 
-#endif /* EDIT */
+#endif /* EMACS */
diff --git a/eval.c b/eval.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: eval.c,v 1.57 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: eval.c,v 1.58 2018/01/14 16:04:21 anton Exp $	*/
 
 /*
  * Expansion - quoting, separation, substitution, globbing
@@ -56,9 +56,7 @@ static	void	globit(XString *, char **, char *, XPtrV *, int);
 static char	*maybe_expand_tilde(char *, XString *, char **, int);
 static	char   *tilde(char *);
 static	char   *homedir(char *);
-#ifdef BRACE_EXPAND
 static void	alt_expand(XPtrV *, char *, char *, char *, int);
-#endif
 
 /* compile and expand word */
 char *
@@ -180,10 +178,8 @@ expand(char *cp,	/* input word */
 		f &= ~DOGLOB;
 	if (Flag(FMARKDIRS))
 		f |= DOMARKDIRS;
-#ifdef BRACE_EXPAND
 	if (Flag(FBRACEEXPAND) && (f & DOGLOB))
 		f |= DOBRACE_;
-#endif /* BRACE_EXPAND */
 
 	Xinit(ds, dp, 128, ATEMP);	/* init dest. string */
 	type = XBASE;
@@ -563,15 +559,12 @@ expand(char *cp,	/* input word */
 
 				*dp++ = '\0';
 				p = Xclose(ds, dp);
-#ifdef BRACE_EXPAND
 				if (fdo & DOBRACE_)
 					/* also does globbing */
 					alt_expand(wp, p, p,
 					    p + Xlength(ds, (dp - 1)),
 					    fdo | (f & DOMARKDIRS));
-				else
-#endif /* BRACE_EXPAND */
-				if (fdo & DOGLOB)
+				else if (fdo & DOGLOB)
 					glob(p, wp, f & DOMARKDIRS);
 				else if ((f & DOPAT) || !(fdo & DOMAGIC_))
 					XPput(*wp, p);
@@ -628,7 +621,6 @@ expand(char *cp,	/* input word */
 						*dp++ = MAGIC;
 					}
 					break;
-#ifdef BRACE_EXPAND
 				case OBRACE:
 				case ',':
 				case CBRACE:
@@ -638,7 +630,6 @@ expand(char *cp,	/* input word */
 						*dp++ = MAGIC;
 					}
 					break;
-#endif /* BRACE_EXPAND */
 				case '=':
 					/* Note first unquoted = for ~ */
 					if (!(f & DOTEMP_) && !saw_eq) {
@@ -1221,7 +1212,6 @@ homedir(char *name)
 	return ap->val.s;
 }
 
-#ifdef BRACE_EXPAND
 static void
 alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo)
 {
@@ -1296,4 +1286,3 @@ alt_expand(XPtrV *wp, char *start, char *exp_start, char *end, int fdo)
 	}
 	return;
 }
-#endif /* BRACE_EXPAND */
diff --git a/exec.c b/exec.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: exec.c,v 1.70 2017/12/27 13:02:57 millert Exp $	*/
+/*	$OpenBSD: exec.c,v 1.71 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * execute command tree
@@ -1239,7 +1239,6 @@ herein(const char *content, int sub)
 	return fd;
 }
 
-#ifdef EDIT
 /*
  *	ksh special - the select command processing section
  *	print the args in column form - assuming that we can
@@ -1365,7 +1364,6 @@ pr_list(char *const *ap)
 
 	return n;
 }
-#endif /* EDIT */
 
 /*
  *	[[ ... ]] evaluation routines
diff --git a/history.c b/history.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: history.c,v 1.78 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: history.c,v 1.80 2018/01/15 22:30:38 jca Exp $	*/
 
 /*
  * command history
@@ -30,8 +30,6 @@
 #include <vis.h>
 #endif
 
-#ifdef HISTORY
-
 static void	history_write(void);
 static FILE	*history_open(void);
 static void	history_load(Source *);
@@ -798,10 +796,9 @@ hist_init(Source *s)
 
 	hist_source = s;
 
-	hname = str_val(global("HISTFILE"));
-	if (hname == NULL)
+	if (str_val(global("HISTFILE")) == null)
 		return;
-	hname = str_save(hname, APERM);
+	hname = str_save(str_val(global("HISTFILE")), APERM);
 	histfh = history_open();
 	if (histfh == NULL)
 		return;
@@ -861,25 +858,3 @@ hist_finish(void)
 {
 	history_close();
 }
-
-#else /* HISTORY */
-
-/* No history to be compiled in: dummy routines to avoid lots more ifdefs */
-void
-init_histvec(void)
-{
-}
-void
-hist_init(Source *s)
-{
-}
-void
-hist_finish(void)
-{
-}
-void
-histsave(int lno, const char *cmd, int dowrite)
-{
-	errorf("history not enabled");
-}
-#endif /* HISTORY */
diff --git a/lex.c b/lex.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: lex.c,v 1.77 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: lex.c,v 1.78 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * lexical analysis and source input
@@ -1086,14 +1086,13 @@ getsc_line(Source *s)
 		ksh_tmout_state = TMOUT_READING;
 		alarm(ksh_tmout);
 	}
-#ifdef EDIT
 	if (have_tty && (0
-# ifdef VI
+#ifdef VI
 	    || Flag(FVI)
-# endif /* VI */
-# ifdef EMACS
+#endif /* VI */
+#ifdef EMACS
 	    || Flag(FEMACS) || Flag(FGMACS)
-# endif /* EMACS */
+#endif /* EMACS */
 	    )) {
 		int nread;
 
@@ -1102,10 +1101,7 @@ getsc_line(Source *s)
 			nread = 0;
 		xp[nread] = '\0';
 		xp += nread;
-	}
-	else
-#endif /* EDIT */
-	{
+	} else {
 		if (interactive) {
 			pprompt(prompt, 0);
 		} else
@@ -1153,7 +1149,6 @@ getsc_line(Source *s)
 			shf_fdclose(s->u.shf);
 		s->str = NULL;
 	} else if (interactive) {
-#ifdef HISTORY
 		char *p = Xstring(s->xs, xp);
 		if (cur_prompt == PS1)
 			while (*p && ctype(*p, C_IFS) && ctype(*p, C_IFSWS))
@@ -1162,7 +1157,6 @@ getsc_line(Source *s)
 			s->line++;
 			histsave(s->line, s->str, 1);
 		}
-#endif /* HISTORY */
 	}
 	if (interactive)
 		set_prompt(PS2);
diff --git a/lex.h b/lex.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: lex.h,v 1.20 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: lex.h,v 1.21 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * Source input, lexer and parser
@@ -105,15 +105,12 @@ extern YYSTYPE	yylval;		/* result from yylex */
 extern struct ioword *heres[HERES], **herep;
 extern char	ident[IDENT+1];
 
-#ifdef HISTORY
-# define HISTORYSIZE	500	/* size of saved history */
+#define HISTORYSIZE	500	/* size of saved history */
 
 extern char   **history;	/* saved commands */
 extern char   **histptr;	/* last history item */
 extern uint32_t	histsize;	/* history size */
 
-#endif /* HISTORY */
-
 int	yylex(int);
 void	yyerror(const char *, ...)
 	    __attribute__((__noreturn__, __format__ (printf, 1, 2)));
diff --git a/main.c b/main.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: main.c,v 1.86 2018/01/05 15:44:31 jca Exp $	*/
+/*	$OpenBSD: main.c,v 1.88 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * startup, main loop, environments and error handling
@@ -69,9 +69,7 @@ int	 builtin_flag;
 char	*current_wd;
 int	 current_wd_size;
 
-#ifdef EDIT
 int	x_cols = 80;
-#endif /* EDIT */
 
 /*
  * shell initialization
@@ -94,9 +92,7 @@ static const char *initcoms [] = {
 	  "stop=kill -STOP",
 	  "autoload=typeset -fu",
 	  "functions=typeset -f",
-#ifdef HISTORY
 	  "history=fc -l",
-#endif /* HISTORY */
 	  "integer=typeset -i",
 	  "nohup=nohup ",
 	  "local=typeset",
@@ -228,9 +224,7 @@ main(int argc, char *argv[])
 	 * brace expansion, so set this before setting up FPOSIX
 	 * (change_flag() clears FBRACEEXPAND when FPOSIX is set).
 	 */
-#ifdef BRACE_EXPAND
 	Flag(FBRACEEXPAND) = 1;
-#endif /* BRACE_EXPAND */
 
 	/* set posix flag just before environment so that it will have
 	 * exactly the same effect as the POSIXLY_CORRECT environment
@@ -253,12 +247,12 @@ main(int argc, char *argv[])
 	/* Set edit mode to emacs by default, may be overridden
 	 * by the environment or the user.  Also, we want tab completion
 	 * on in vi by default. */
-#if defined(EDIT) && defined(EMACS)
+#if defined(EMACS)
 	change_flag(FEMACS, OF_SPECIAL, 1);
-#endif /* EDIT && EMACS */
-#if defined(EDIT) && defined(VI)
+#endif /* EMACS */
+#if defined(VI)
 	Flag(FVITABCOMPLETE) = 1;
-#endif /* EDIT && VI */
+#endif /* VI */
 
 	/* import environment */
 	if (environ != NULL)
@@ -371,11 +365,9 @@ main(int argc, char *argv[])
 	i = Flag(FMONITOR) != 127;
 	Flag(FMONITOR) = 0;
 	j_init(i);
-#ifdef EDIT
 	/* Do this after j_init(), as tty_fd is not initialized 'til then */
 	if (Flag(FTALKING))
 		x_init();
-#endif
 
 	l = genv->loc;
 	l->argv = make_argv(argc - (argi - 1), &argv[argi - 1]);
diff --git a/misc.c b/misc.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: misc.c,v 1.65 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: misc.c,v 1.67 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * Miscellaneous functions
@@ -121,9 +121,7 @@ const struct option sh_options[] = {
 	 * entries MUST match the order of sh_flag F* enumerations in sh.h.
 	 */
 	{ "allexport",	'a',		OF_ANY },
-#ifdef BRACE_EXPAND
 	{ "braceexpand",  0,		OF_ANY }, /* non-standard */
-#endif
 	{ "bgnice",	  0,		OF_ANY },
 	{ NULL,	'c',	    OF_CMDLINE },
 	{ "csh-history",  0,		OF_ANY }, /* non-standard */
@@ -272,27 +270,25 @@ change_flag(enum sh_flag f,
 		if (what != OF_CMDLINE && newval != oldval)
 			j_change();
 	} else
-#ifdef EDIT
 	if (0
-# ifdef VI
+#ifdef VI
 	    || f == FVI
-# endif /* VI */
-# ifdef EMACS
+#endif /* VI */
+#ifdef EMACS
 	    || f == FEMACS || f == FGMACS
-# endif /* EMACS */
+#endif /* EMACS */
 	   )
 	{
 		if (newval) {
-# ifdef VI
+#ifdef VI
 			Flag(FVI) = 0;
-# endif /* VI */
-# ifdef EMACS
+#endif /* VI */
+#ifdef EMACS
 			Flag(FEMACS) = Flag(FGMACS) = 0;
-# endif /* EMACS */
+#endif /* EMACS */
 			Flag(f) = newval;
 		}
 	} else
-#endif /* EDIT */
 	/* Turning off -p? */
 	if (f == FPRIVILEGED && oldval && !newval) {
 		gid_t gid = getgid();
@@ -301,10 +297,7 @@ change_flag(enum sh_flag f,
 		setgroups(1, &gid);
 		setresuid(ksheuid, ksheuid, ksheuid);
 	} else if (f == FPOSIX && newval) {
-#ifdef BRACE_EXPAND
-		Flag(FBRACEEXPAND) = 0
-#endif /* BRACE_EXPAND */
-		;
+		Flag(FBRACEEXPAND) = 0;
 	}
 	/* Changing interactive flag? */
 	if (f == FTALKING) {
diff --git a/sh.h b/sh.h
@@ -1,4 +1,4 @@
-/*	$OpenBSD: sh.h,v 1.68 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: sh.h,v 1.70 2018/01/15 14:58:05 jca Exp $	*/
 
 /*
  * Public Domain Bourne/Korn shell
@@ -132,9 +132,7 @@ extern const struct option sh_options[];
  */
 enum sh_flag {
 	FEXPORT = 0,	/* -a: export all */
-#ifdef BRACE_EXPAND
 	FBRACEEXPAND,	/* enable {} globbing */
-#endif
 	FBGNICE,	/* bgnice */
 	FCOMMAND,	/* -c: (invocation) execute specified command */
 	FCSHHISTORY,	/* csh-style history enabled */
@@ -340,18 +338,14 @@ extern int	builtin_flag;	/* flags of called builtin (SPEC_BI, etc.) */
 extern char	*current_wd;
 extern int	current_wd_size;
 
-#ifdef EDIT
 /* Minimum required space to work with on a line - if the prompt leaves less
  * space than this on a line, the prompt is truncated.
  */
-# define MIN_EDIT_SPACE	7
+#define MIN_EDIT_SPACE	7
 /* Minimum allowed value for x_cols: 2 for prompt, 3 for " < " at end of line
  */
-# define MIN_COLS	(2 + MIN_EDIT_SPACE + 3)
+#define MIN_COLS	(2 + MIN_EDIT_SPACE + 3)
 extern	int	x_cols;	/* tty columns */
-#else
-# define x_cols 80		/* for pr_menu(exec.c) */
-#endif
 
 /* These to avoid bracket matching problems */
 #define OPAREN	'('
@@ -453,7 +447,6 @@ void	init_histvec(void);
 void	hist_init(Source *);
 void	hist_finish(void);
 void	histsave(int, const char *, int);
-#ifdef HISTORY
 int	c_fc(char **);
 void	sethistcontrol(const char *);
 void	sethistsize(int);
@@ -464,7 +457,6 @@ int	findhist(int, int, const char *, int);
 int	findhistrel(const char *);
 char  **hist_get_newest(int);
 
-#endif /* HISTORY */
 /* io.c */
 void	errorf(const char *, ...)
 	    __attribute__((__noreturn__, __format__ (printf, 1, 2)));
diff --git a/var.c b/var.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: var.c,v 1.63 2018/01/06 16:28:58 millert Exp $	*/
+/*	$OpenBSD: var.c,v 1.64 2018/01/15 14:58:05 jca Exp $	*/
 
 #include <sys/stat.h>
 
@@ -97,15 +97,11 @@ initvar(void)
 		{ "PATH",		V_PATH },
 		{ "POSIXLY_CORRECT",	V_POSIXLY_CORRECT },
 		{ "TMPDIR",		V_TMPDIR },
-#ifdef HISTORY
 		{ "HISTCONTROL",	V_HISTCONTROL },
 		{ "HISTFILE",		V_HISTFILE },
 		{ "HISTSIZE",		V_HISTSIZE },
-#endif /* HISTORY */
-#ifdef EDIT
 		{ "EDITOR",		V_EDITOR },
 		{ "VISUAL",		V_VISUAL },
-#endif /* EDIT */
 		{ "MAIL",		V_MAIL },
 		{ "MAILCHECK",		V_MAILCHECK },
 		{ "MAILPATH",		V_MAILPATH },
@@ -933,13 +929,11 @@ getspec(struct tbl *vp)
 		setint(vp, (long) (rand() & 0x7fff));
 		vp->flag |= SPECIAL;
 		break;
-#ifdef HISTORY
 	case V_HISTSIZE:
 		vp->flag &= ~SPECIAL;
 		setint(vp, (long) histsize);
 		vp->flag |= SPECIAL;
 		break;
-#endif /* HISTORY */
 	case V_OPTIND:
 		vp->flag &= ~SPECIAL;
 		setint(vp, (long) user_opt.uoptind);
@@ -991,7 +985,6 @@ setspec(struct tbl *vp)
 				tmpdir = str_save(s, APERM);
 		}
 		break;
-#ifdef HISTORY
 	case V_HISTCONTROL:
 		sethistcontrol(str_val(vp));
 		break;
@@ -1003,8 +996,6 @@ setspec(struct tbl *vp)
 	case V_HISTFILE:
 		sethistfile(str_val(vp));
 		break;
-#endif /* HISTORY */
-#ifdef EDIT
 	case V_VISUAL:
 		set_editmode(str_val(vp));
 		break;
@@ -1026,7 +1017,6 @@ setspec(struct tbl *vp)
 				x_cols = l;
 		}
 		break;
-#endif /* EDIT */
 	case V_MAIL:
 		mbset(str_val(vp));
 		break;
@@ -1086,11 +1076,9 @@ unsetspec(struct tbl *vp)
 	case V_MAILPATH:
 		mpset(NULL);
 		break;
-#ifdef HISTORY
 	case V_HISTCONTROL:
 		sethistcontrol(NULL);
 		break;
-#endif
 	case V_LINENO:
 	case V_MAILCHECK:	/* at&t ksh leaves previous value in place */
 	case V_RANDOM: