bash: nested interactive read within a loop that's also using read

Viewed 2954

How does one code an interactive response in this while loop?

#!/bin/bash

shows=$(< ${HOME}/.get_iplayer/tv.cache)

# ...
# ... stuff with shows omitted ...
# ...

function print_show {
# ...
    return
}

while read -r line
do
    print_show "$line"

    read -n 1 -p "do stuff? [y/n] : " resp  # PROBLEM

# ...
# resp actions omitted
# ...

done <<< "$shows"

So a file is read, "processed" then the resulting line oriented data is used in a while read loop

But the read line within the while loop doesn't work as intended, that is it doesn't wait for the user response, presumably due to the while read context it is encapsulated by.

Could you please suggest how to fix this or an alternate mechanism?

2 Answers
Related