-/* $OpenBSD: history.c,v 1.56 2015/12/30 09:07:00 tedu Exp $ */
+/* $OpenBSD: history.c,v 1.57 2016/08/24 13:32:17 millert Exp $ */
/*
* command history
struct temp *tf = NULL;
char *p, *editor = NULL;
int gflag = 0, lflag = 0, nflag = 0, sflag = 0, rflag = 0;
- int optc;
+ int optc, ret;
char *first = NULL, *last = NULL;
char **hfirst, **hlast, **hp;
+ static int depth;
+
+ if (depth != 0) {
+ bi_errorf("history function called recursively");
+ return 1;
+ }
if (!Flag(FTALKING_I)) {
bi_errorf("history functions not available");
hist_get_newest(false);
if (!hp)
return 1;
- return hist_replace(hp, pat, rep, gflag);
+ depth++;
+ ret = hist_replace(hp, pat, rep, gflag);
+ depth--;
+ return ret;
}
if (editor && (lflag || nflag)) {
/* XXX: source should not get trashed by this.. */
{
Source *sold = source;
- int ret;
ret = command(editor ? editor : "${FCEDIT:-/bin/ed} $_", 0);
source = sold;
shf_close(shf);
*xp = '\0';
strip_nuls(Xstring(xs, xp), Xlength(xs, xp));
- return hist_execute(Xstring(xs, xp));
+ depth++;
+ ret = hist_execute(Xstring(xs, xp));
+ depth--;
+ return ret;
}
}