From 3e9ecaf1ece2d3e4ddee22c562f022e8176ee973 Mon Sep 17 00:00:00 2001 From: "Todd C. Miller" Date: Wed, 9 Jun 2010 10:45:07 -0400 Subject: [PATCH] Make TGP_ECHO override TGP_MASK and don't try to restore the terminal if we didn't modify it. --- src/tgetpass.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/tgetpass.c b/src/tgetpass.c index 56a2c489f..cfc7e08f6 100644 --- a/src/tgetpass.c +++ b/src/tgetpass.c @@ -120,10 +120,12 @@ restart: * If we are using a tty but are not the foreground pgrp this will * generate SIGTTOU, so do it *before* installing the signal handlers. */ - if (ISSET(flags, TGP_MASK)) - neednl = term_cbreak(input); - else if (!ISSET(flags, TGP_ECHO)) - neednl = term_noecho(input); + if (!ISSET(flags, TGP_ECHO)) { + if (ISSET(flags, TGP_MASK)) + neednl = term_cbreak(input); + else + neednl = term_noecho(input); + } /* * Catch signals that would otherwise cause the user to end @@ -155,7 +157,8 @@ restart: (void) write(output, "\n", 1); /* Restore old tty settings and signals. */ - term_restore(input, 1); + if (!ISSET(flags, TGP_ECHO)) + term_restore(input, 1); (void) sigaction(SIGALRM, &savealrm, NULL); (void) sigaction(SIGINT, &saveint, NULL); (void) sigaction(SIGHUP, &savehup, NULL); -- 2.40.0