I've written a small C program that uses readline("")
to read input from stdin. Rather than interacting with it from the terminal, I've written a test harness which executes the C program and gives it input:
test harness --stdout--> | --stdin--> C program
^------stdin--- | <--stdout-----/
This test harness is receiving an echo of its output, even though the program itself. Why is readline() echoing its input, and can I disable this? Or should I not be using readline() in a non-interactive environment?
The readline library is solely intended for interactive use. Your program should probably fall back to using fgets()
if isatty(STDIN_FILENO)
is false.