From 257eea612a27a0ee81d4c61aba91c8f48f7de4b7 Mon Sep 17 00:00:00 2001 From: Martijn Dekker Date: Wed, 17 Nov 2021 04:00:13 +0100 Subject: [PATCH] edit.c: don't trace tput command on init (re: ef8b80cf) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/cmd/ksh93/edit/edit.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/cmd/ksh93/edit/edit.c b/src/cmd/ksh93/edit/edit.c index f48f83741..d09aa32f4 100644 --- a/src/cmd/ksh93/edit/edit.c +++ b/src/cmd/ksh93/edit/edit.c @@ -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)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