aboutsummaryrefslogtreecommitdiffstats
path: root/bin
diff options
context:
space:
mode:
Diffstat (limited to 'bin')
-rw-r--r--bin/ykfde.c13
1 files changed, 5 insertions, 8 deletions
diff --git a/bin/ykfde.c b/bin/ykfde.c
index 56e2e0c..96b5559 100644
--- a/bin/ykfde.c
+++ b/bin/ykfde.c
@@ -64,17 +64,14 @@ char * ask_secret(const char * text) {
char * factor = NULL;
size_t len;
ssize_t readlen;
- bool onTerminal = true;
+ bool onTerminal = false;
/* get terminal properties */
- if (tcgetattr(STDIN_FILENO, &tp) < 0) {
- onTerminal = false;
- } else {
+ if (tcgetattr(STDIN_FILENO, &tp) == 0) {
+ onTerminal = true;
tp_save = tp;
- }
- /* disable echo on terminal */
- if (onTerminal) {
+ /* disable echo on terminal */
tp.c_lflag &= ~ECHO;
if (tcsetattr(STDIN_FILENO, TCSAFLUSH, &tp) < 0) {
fprintf(stderr, "Failed setting terminal attributes.\n");
@@ -87,7 +84,7 @@ char * ask_secret(const char * text) {
readlen = getline(&factor, &len, stdin);
factor[readlen - 1] = '\0';
- if (onTerminal) {
+ if (onTerminal == true) {
putchar('\n');
/* restore terminal */