Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix IO::CatHandle.read switching handles too soon
Fixes #1313: #1313 The logic is: read some stuff do we have enough stuff? -> [yes] -> return stuff -> [no] is current handle EOF or did we read zero stuff on last chunk? -> [yes] -> switch handle -> repeat from start -> [no] return stuff The extra gymnastics are due to: (a) possibility of TTY handles returning fewer than requested number of bytes without being entirely exhausted. This means when we read fewer than $bytes bytes, we don't yet know whether we should switch the handle and thus, if we read at least some bytes in a chunk and don't have EOF, we gotta return whatever we managed to read (b) XXX TODO: (this actually seems to be a bug) possibility of .seek being used on current handle. In such a case we can read a zero-sized chunk and EOF would still be false
- Loading branch information