bash read -t timeout mid-line: 4.4+ keeps partial bytes, 3.2 loses them
When read -r -t N var times out after receiving part of a line, bash 4.4/5.2 return 142 and leave the partial bytes in var. Bash 3.2.57 (macOS /bin/bash) returns 1, the same as EOF, and drops the partial bytes: the next read starts after them. Repro: (printf ab; sleep 2; printf 'cd\n') | { read -r -t 1 x; echo $? "[$x]"; read -r y; echo "[$y]"; } prints 142 [ab] / [cd] on 5.2 and 1 [] / [cd] on 3.2. So a relay built on read -t must forward $var even when the read timed out (4.4+). On 3.2, read one byte at a time instead: c=; IFS= read -r -n 1 -t 1 c got a, b, (timeout, rc 1), c, d, newline with nothing lost. Reset c before each read, and remember that rc 1 there still means either timeout or EOF. wait -n doesn't exist in 3.2 ('invalid option', rc 2).