1
0
Fork 0
mirror of git://git.code.sf.net/p/cdesktopenv/code synced 2025-02-13 03:32:24 +00:00

edit.c: don't trace tput command on init (re: ef8b80cf)

When starting a new interactive ksh with the -v or -x option, an
annoying symptom occurs: the 'tput' command that ed_setup() issues
to get the escape sequence for cursor-up is xtraced or echoed,
corrupting prompt display, for example ('▂' is the cursor):
	$ ksh -x
	$ + /usr/bin/tput cuu1
	+ 2> /dev/null
	+ .sh.subscript=$'\E[A'
	▂
or
	$ ksh -v
	$ .sh.subscript=$(/usr/bin/tput cuu1 2>/dev/null)▂

src/cmd/ksh93/edit/edit.c: ed_setup():
- Turn off xtrace and verbose while sh_trap()ing tput.
This commit is contained in:
Martijn Dekker 2021-11-17 04:00:13 +01:00
parent 54674cb325
commit 257eea612a

View file

@ -811,9 +811,11 @@ void ed_setup(register Edit_t *ep, int fd, int reedit)
ep->e_term = nv_search("TERM",shp->var_tree,0);
if(ep->e_term && (term=nv_getval(ep->e_term)) && strlen(term)<sizeof(ep->e_termname) && strcmp(term,ep->e_termname))
{
char was_restricted = (sh_isoption(SH_RESTRICTED)!=0);
Shopt_t o = shp->options;
sigblock(SIGINT);
sh_offoption(SH_RESTRICTED);
sh_offoption(SH_VERBOSE);
sh_offoption(SH_XTRACE);
#if _tput_terminfo
sh_trap(".sh.subscript=$(" _pth_tput " cuu1 2>/dev/null)",0);
#elif _tput_termcap
@ -827,8 +829,7 @@ void ed_setup(register Edit_t *ep, int fd, int reedit)
CURSOR_UP[0] = '\0'; /* no escape sequence is better than a faulty one */
nv_unset(SH_SUBSCRNOD);
strcpy(ep->e_termname,term);
if(was_restricted)
sh_onoption(SH_RESTRICTED);
shp->options = o;
sigrelease(SIGINT);
}
#endif