I have a shell script that can read from a file or from standard input. Currently, if you don't give it a file or pipe text into it, it starts accepting input at the command prompt.
Instead, I would like to print "help" information in this scenario. Is there a standard way to do this? And if not, is there a way to detect standard input without affecting it? Or is there a way to detect where the would-be input is coming from?
I know that the
read command can tell me whether there's input via its exit status. But it also acts on the input, affecting subsequent reads.