-/* $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_*
{"+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},
-/* $OpenBSD: config.h,v 1.18 2018/01/14 16:04:21 anton Exp $ */
+/* $OpenBSD: config.h,v 1.19 2018/01/15 14:58:05 jca Exp $ */
/* config.h. NOT generated automatically. */
#ifndef CONFIG_H
#define CONFIG_H
-/* Include any history? */
-#define HISTORY 1
-
/* Strict POSIX behaviour? */
/* #undef POSIXLY_CORRECT */
* 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 */
-
#endif /* CONFIG_H */
-/* $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
*/
#include "config.h"
-#ifdef EDIT
#include <sys/ioctl.h>
#include <sys/stat.h>
return (rval);
}
-#endif /* EDIT */
-/* $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
return fd;
}
-#ifdef EDIT
/*
* ksh special - the select command processing section
* print the args in column form - assuming that we can
return n;
}
-#endif /* EDIT */
/*
* [[ ... ]] evaluation routines
-/* $OpenBSD: history.c,v 1.78 2018/01/06 16:28:58 millert Exp $ */
+/* $OpenBSD: history.c,v 1.79 2018/01/15 14:58:05 jca Exp $ */
/*
* command history
#include "sh.h"
-#ifdef HISTORY
-
static void history_write(void);
static FILE *history_open(void);
static void history_load(Source *);
{
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 */
-/* $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
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;
nread = 0;
xp[nread] = '\0';
xp += nread;
- }
- else
-#endif /* EDIT */
- {
+ } else {
if (interactive) {
pprompt(prompt, 0);
} else
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))
s->line++;
histsave(s->line, s->str, 1);
}
-#endif /* HISTORY */
}
if (interactive)
set_prompt(PS2);
-/* $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
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)));
-/* $OpenBSD: main.c,v 1.87 2018/01/14 16:04:21 anton Exp $ */
+/* $OpenBSD: main.c,v 1.88 2018/01/15 14:58:05 jca Exp $ */
/*
* startup, main loop, environments and error handling
char *current_wd;
int current_wd_size;
-#ifdef EDIT
int x_cols = 80;
-#endif /* EDIT */
/*
* shell initialization
"stop=kill -STOP",
"autoload=typeset -fu",
"functions=typeset -f",
-#ifdef HISTORY
"history=fc -l",
-#endif /* HISTORY */
"integer=typeset -i",
"nohup=nohup ",
"local=typeset",
/* 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)
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]);
-/* $OpenBSD: misc.c,v 1.66 2018/01/14 16:04:21 anton Exp $ */
+/* $OpenBSD: misc.c,v 1.67 2018/01/15 14:58:05 jca Exp $ */
/*
* Miscellaneous functions
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();
-/* $OpenBSD: sh.h,v 1.69 2018/01/14 16:04:21 anton Exp $ */
+/* $OpenBSD: sh.h,v 1.70 2018/01/15 14:58:05 jca Exp $ */
/*
* Public Domain Bourne/Korn shell
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 '('
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);
int findhistrel(const char *);
char **hist_get_newest(int);
-#endif /* HISTORY */
/* io.c */
void errorf(const char *, ...)
__attribute__((__noreturn__, __format__ (printf, 1, 2)));
-/* $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>
{ "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 },
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);
tmpdir = str_save(s, APERM);
}
break;
-#ifdef HISTORY
case V_HISTCONTROL:
sethistcontrol(str_val(vp));
break;
case V_HISTFILE:
sethistfile(str_val(vp));
break;
-#endif /* HISTORY */
-#ifdef EDIT
case V_VISUAL:
set_editmode(str_val(vp));
break;
x_cols = l;
}
break;
-#endif /* EDIT */
case V_MAIL:
mbset(str_val(vp));
break;
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: