echo "a" | if read -t 0 a ; then echo $a; a=cleared; if read -t 0 a; then echo $a; fi; fi outputs blah cleared I'm a little confused by this. Would expect the second read to return failure, but it does not. Indeed, any subsequent reads on the same pipe return true. Can work around by using -t 0.001 but it seems a little odd.
And immediately after I hit "send" I realised that the first read is also not populating $a either - my initial tests were with "blah", I hadn't realised that it hadn't changed to "a" as expected. So read -t 0 a simply doesn't populate a at all, but returns true.
This actually matches other shells' behaviour, even though unexpected on my part. Apologies for timewasting.