I have a rake task that I would like to be optionally given stdin, e.g. either of the following could work:
rake my_task
cat foo.txt | rake my_task
The problem is that I don't have a reliable way to check whether STDIN was given to the program. Here's my current attempt, which just hangs indeterminately:
instructions = STDIN.read.split("\n") if STDIN.tty?
I added the STDIN.tty?
after reading how-can-you-check-for-stdin-input-in-a-ruby-script. It is returning true
when I invoke it with rake my_task
(no stdin)