1
0
mirror of https://github.com/openbsd/src.git synced 2026-06-19 07:43:34 +02:00

Inspecting Flag(FTALKING) to activate curses in the spot chosen by the

previous commit seems to fail in some circumstances because of order
of operations in ksh startup.  So move the test and curses initialization
immediately before the tputs() calls.
discussion with tb
This commit is contained in:
deraadt
2026-03-05 05:38:58 +00:00
parent d17ee606c0
commit 009ff5eaef
4 changed files with 22 additions and 17 deletions
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: emacs.c,v 1.90 2023/06/21 22:22:08 millert Exp $ */
/* $OpenBSD: emacs.c,v 1.91 2026/03/05 05:38:58 deraadt Exp $ */
/*
* Emacs-like command line editing and history
@@ -1033,6 +1033,8 @@ x_redraw(int limit)
if (limit == -2) {
int cleared = 0;
#ifndef SMALL
if (cur_term == NULL && Flag(FTALKING))
initcurses();
if (cur_term != NULL && clear_screen != NULL) {
if (tputs(clear_screen, 1, x_putc) != ERR)
cleared = 1;
+2 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: sh.h,v 1.77 2023/06/21 22:22:08 millert Exp $ */
/* $OpenBSD: sh.h,v 1.78 2026/03/05 05:38:58 deraadt Exp $ */
/*
* Public Domain Bourne/Korn shell
@@ -602,4 +602,5 @@ void change_random(void);
int array_ref_len(const char *);
char * arrayname(const char *);
void set_array(const char *, int, char **);
void initcurses(void);
/* vi.c: see edit.h */
+14 -14
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: var.c,v 1.74 2026/03/04 03:54:25 deraadt Exp $ */
/* $OpenBSD: var.c,v 1.75 2026/03/05 05:38:58 deraadt Exp $ */
#include <sys/stat.h>
#include <sys/time.h>
@@ -117,7 +117,6 @@ initvar(void)
{ "SECONDS", V_SECONDS },
{ "TMOUT", V_TMOUT },
{ "LINENO", V_LINENO },
{ "TERM", V_TERM },
{ NULL, 0 }
};
int i;
@@ -1070,18 +1069,6 @@ setspec(struct tbl *vp)
user_lineno = (unsigned int) intval(vp) - current_lineno - 1;
vp->flag |= SPECIAL;
break;
case V_TERM:
#ifndef SMALL
if (Flag(FTALKING)) {
int ret;
vp->flag &= ~SPECIAL;
if (setupterm(str_val(vp), shl_out->fd, &ret) == ERR)
del_curterm(cur_term);
vp->flag |= SPECIAL;
}
#endif
break;
}
}
@@ -1242,3 +1229,16 @@ set_array(const char *var, int reset, char **vals)
setstr(vq, vals[i], KSH_RETURN_ERROR);
}
}
void
initcurses(void)
{
struct tbl *vp = global("TERM");
int ret;
if (vp) {
if (setupterm(str_val(vp),
shl_out->fd, &ret) == ERR)
del_curterm(cur_term);
}
}
+3 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: vi.c,v 1.67 2025/07/20 21:24:07 schwarze Exp $ */
/* $OpenBSD: vi.c,v 1.68 2026/03/05 05:38:58 deraadt Exp $ */
/*
* vi command editing
@@ -1739,6 +1739,8 @@ do_clear_screen(void)
int neednl = 1;
#ifndef SMALL
if (cur_term == NULL && Flag(FTALKING))
initcurses();
if (cur_term != NULL && clear_screen != NULL) {
if (tputs(clear_screen, 1, x_putc) != ERR)
neednl = 0;