You've correctly identified that the cause is that within the
while ...; do ...; done <<< "$shows"
loop, stdin has been redirected, thus read
is no longer reading from the keyboard.
You can solve this by using a file descriptor other than 0; for example,
while read -r -u 3 line; do ...; done 3<${HOME}/.get_iplayer/tv.cache
will use FD 3 for the file rather than FD 0, allowing the normal read
(without -u
) to use original stdin, or
while ...; do read -n 1 -p "do stuff? [y/n] : " -u 3 resp; done 3<&0 <<< "$shows"
to clone the original FD 0 to FD 3 before replacing FD 0 with your string.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…