3 ms·
So to check if there's anything sitting on stdin without reading it I've been using `if read -r -t0; then` # returns true if there is data but times out instan
by pmarreck 3y ago
So to check if there's anything sitting on stdin without reading it I've been using
`if read -r -t0; then` # returns true if there is data but times out instantly so it doesn't consume any
Is `[ -t 0 ]` more idiomatic? Apparently it fails on this case: function < file
`read -r -t0` is Bash-only though and not POSIX, but it will work regardless of what type of data is on stdin
- naniwaduni 3y ago[ -t 0 ] instead checks whether stdin (fd 0) is a tty.