parent
2e8c168ee1
commit
8731fd65f8
@ -0,0 +1,31 @@
|
|||||||
|
From d429d07e5546d642e3b08bc0d54790838f0b160d Mon Sep 17 00:00:00 2001
|
||||||
|
From: Kevin Cernekee <cernekee@gmail.com>
|
||||||
|
Date: Thu, 14 Jul 2016 13:15:49 -0700
|
||||||
|
Subject: [PATCH] Skip extra newline when run from scripts
|
||||||
|
|
||||||
|
A user can use an invocation like `echo 1234 | stoken --stdin tokencode`
|
||||||
|
to run stoken from a shell script. This currently outputs an extra
|
||||||
|
newline character because that is necessary for interactive prompts,
|
||||||
|
making it harder to parse the output. Skip the newline if stdin is not
|
||||||
|
a tty.
|
||||||
|
|
||||||
|
Fixes #29.
|
||||||
|
|
||||||
|
Signed-off-by: Kevin Cernekee <cernekee@gmail.com>
|
||||||
|
---
|
||||||
|
src/cli.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/cli.c b/src/cli.c
|
||||||
|
index 1b7ffcb..1f180cd 100644
|
||||||
|
--- a/src/cli.c
|
||||||
|
+++ b/src/cli.c
|
||||||
|
@@ -101,7 +101,7 @@ static int plat_read_user_input(char *out, int max_len, int hide_chars)
|
||||||
|
|
||||||
|
done:
|
||||||
|
stdin_echo(1);
|
||||||
|
- if (hide_chars)
|
||||||
|
+ if (hide_chars && isatty(fileno(stdin)))
|
||||||
|
puts("");
|
||||||
|
return ret;
|
||||||
|
}
|
Loading…
Reference in new issue