On 2/4/19 11:45 AM, John Passaro wrote: > Bash Version: 4.4 > Patch Level: 23 > Release Status: release > > Description: > The `read` builtin skips null characters and does not count > them toward the limit specified by -n/-N. This leads to > surprising behavior with /dev/zero: read -N 1 </dev/zero > never terminates! > > This is obviously a corner case but it violates what ought > to be a safe user assumption that specifying -N prevents > read from running for too long. > > Repeat-By: > $ tr \\0 a </dev/zero | read -N # terminates immediately > $ tr \\0 \\0 </dev/zero | read -N # runs forever > > or in the absence of /dev/zero: > $ while true ; do echo -n a ; done | read -N 1 # terminates > $ while true ; do echo -n a ; done | tr a \\0 | read -N 1 # runs forever > > Fix: > I propose to count nulls toward nchars.
Thanks for the proposal. I'll keep it in mind for a future version. Chet -- ``The lyf so short, the craft so long to lerne.'' - Chaucer ``Ars longa, vita brevis'' - Hippocrates Chet Ramey, UTech, CWRU c...@case.edu http://tiswww.cwru.edu/~chet/