Pipetest
clitest
and stdin don't always work well together.
StackOverflow wasn't much help (shocked pikachu)! Buried deep in the interwebs is the bash advice
to check for a TTY and whether stdin was piped with this: if [ ! -t 0 ] && [ -p /dev/stdin ];
.
Using this, I wanted to see how to do something similar in Python to make clitest work. Even
deeper on the internet was this gem, which led me to
the answer - use stat
in Python to test whether stdin is a FIFO (pipe).
Thus, the answer to this hours long search is simply this function: