ksh: how to probe stdin?
问题 I want my ksh script to have different behaviors depending on whether there is something incoming through stdin or not: (1) cat file.txt | ./script.ksh (then do "cat <&0 >./tmp.dat" and process tmp.dat) vs. (2) ./script.ksh (then process $1 which must be a readable regular file) Checking for stdin to see if it is a terminal[ -t 0 ] is not helpful, because my script is called from an other script. Doing "cat <&0 >./tmp.dat" to check tmp.dat's size hangs up waiting for an EOF from stdin if