As shown below, first loop aims at reading steps from a text file while the second loop is intended to accept an option from user according to what user has seen on the screen, and do something, say configuring package.use or something else, and then go on executing the next step, until the end of steps.
The problem is the second while loop will neither show up options nor continuously read steps from text file, it just exits both of while loops after executing first step of steps, in this case, it shows up the result of executing emerge --pretend ceph and exits both of loops.
steps text file:
ceph
jdk
firefox
...
nested while loop:
#/bin/bash
STEPS="./steps"
while read -r line;
do
if [[ ! $line = "#"* ]]; then
emerge --pretend $line
while read -p 'Please choose something:(1:package.use 2:package.license 3:package.keywords) ' input;
do
case $input in
1) echo "$input has been chosen."
#set up package.use
;;
...
esac
done
fi
done <$STEPS
while, what matters is that it is attempting toreadfrom the user inside areadloop that's already been redirected. The solutions posted in that question will work for your problem as well../steps, and thus everything inside that loop (including the entire inner loop) also shares the same redirected I/O. Thus, your innerreadis also reading from./steps.