PR/50863: John Hein: libedit el_end() messes up term settings if piped
Keep track if we initialized the tty, and only reset it if we did.
This commit is contained in:
parent
bdb04d1c84
commit
a1f44db787
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty.c,v 1.57 2016/02/17 19:47:49 christos Exp $ */
|
||||
/* $NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -37,7 +37,7 @@
|
|||
#if 0
|
||||
static char sccsid[] = "@(#)tty.c 8.1 (Berkeley) 6/4/93";
|
||||
#else
|
||||
__RCSID("$NetBSD: tty.c,v 1.57 2016/02/17 19:47:49 christos Exp $");
|
||||
__RCSID("$NetBSD: tty.c,v 1.58 2016/02/27 18:13:21 christos Exp $");
|
||||
#endif
|
||||
#endif /* not lint && not SCCSID */
|
||||
|
||||
|
@ -498,6 +498,7 @@ tty_setup(EditLine *el)
|
|||
{
|
||||
int rst = 1;
|
||||
|
||||
el->el_tty.t_initialized = 0;
|
||||
if (el->el_flags & EDIT_DISABLED)
|
||||
return 0;
|
||||
|
||||
|
@ -560,6 +561,7 @@ tty_setup(EditLine *el)
|
|||
|
||||
tty__setchar(&el->el_tty.t_ed, el->el_tty.t_c[ED_IO]);
|
||||
tty_bind_char(el, 1);
|
||||
el->el_tty.t_initialized = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -585,6 +587,9 @@ tty_end(EditLine *el)
|
|||
if (el->el_flags & EDIT_DISABLED)
|
||||
return;
|
||||
|
||||
if (el->el_tty.t_initialized)
|
||||
return;
|
||||
|
||||
if (tty_setty(el, TCSAFLUSH, &el->el_tty.t_or) == -1) {
|
||||
#ifdef DEBUG_TTY
|
||||
(void) fprintf(el->el_errfile,
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
/* $NetBSD: tty.h,v 1.18 2016/02/16 15:53:48 christos Exp $ */
|
||||
/* $NetBSD: tty.h,v 1.19 2016/02/27 18:13:21 christos Exp $ */
|
||||
|
||||
/*-
|
||||
* Copyright (c) 1992, 1993
|
||||
|
@ -472,8 +472,9 @@ typedef struct {
|
|||
int t_tabs;
|
||||
int t_eight;
|
||||
speed_t t_speed;
|
||||
int t_mode;
|
||||
unsigned char t_mode;
|
||||
unsigned char t_vdisable;
|
||||
unsigned char t_initialized;
|
||||
} el_tty_t;
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue