When gpioset interactive mode is used as intended, as a human controlled interface, stdout should be a tty. By leaving out the prompt when stdout is not a tty, gpioset interactive mode can be used as a really simple deamon for controlling GPIOs by connecting it to a FIFO. Signed-off-by: Esben Haabendal <esben@xxxxxxxxxx> --- tools/gpioset.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/tools/gpioset.c b/tools/gpioset.c index 9dc5aeb8b286..a1ca211febd7 100644 --- a/tools/gpioset.c +++ b/tools/gpioset.c @@ -742,13 +742,12 @@ static void interact(struct gpiod_line_request **requests, { int num_words, num_lines, max_words, period_us, i; char *line, **words, *line_buf; - bool done, stdout_is_tty; + bool done; stifle_history(20); rl_attempted_completion_function = tab_completion; rl_basic_word_break_characters = " =\""; completion_context = resolver; - stdout_is_tty = isatty(1); max_words = resolver->num_lines + 1; words = calloc(max_words, sizeof(*words)); @@ -757,12 +756,9 @@ static void interact(struct gpiod_line_request **requests, for (done = false; !done;) { /* - * manually print the prompt, as libedit doesn't if stdout - * is not a tty. And fflush to ensure the prompt and any - * output buffered from the previous command is sent. + * fflush to ensure the prompt and any output buffered from the + * previous command is sent. */ - if (!stdout_is_tty) - printf(PROMPT); fflush(stdout); line = readline(PROMPT); -- 2.40.1