summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Christian Hesse <mail@eworm.de>2017-06-14 10:10:32 +0200
committerGravatar Christian Hesse <mail@eworm.de>2017-06-14 10:10:32 +0200
commit778bc2efdc8835e73bd22a16dcb059634b2c2826 (patch)
treecd826e790c94b67d7a19c86680a96d1accf5cf9c
parenta0963c8ae93d2c70d61bb4ed34c46f3497b66690 (diff)
downloadmkinitcpio-ykfde-778bc2efdc8835e73bd22a16dcb059634b2c2826.tar.gz
mkinitcpio-ykfde-778bc2efdc8835e73bd22a16dcb059634b2c2826.tar.zst
invert condition
-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 */