diff --git a/d429d07e5546d642e3b08bc0d54790838f0b160d.patch b/d429d07e5546d642e3b08bc0d54790838f0b160d.patch new file mode 100644 index 0000000..1df5750 --- /dev/null +++ b/d429d07e5546d642e3b08bc0d54790838f0b160d.patch @@ -0,0 +1,31 @@ +From d429d07e5546d642e3b08bc0d54790838f0b160d Mon Sep 17 00:00:00 2001 +From: Kevin Cernekee +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 +--- + 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; + } diff --git a/stoken.spec b/stoken.spec index 66ea680..7ceb187 100644 --- a/stoken.spec +++ b/stoken.spec @@ -70,7 +70,7 @@ This package contains the graphical interface program for %{name}. %prep %setup -q -%patch0 +%patch0 -p1 %build autoreconf -v -f --install