For my purpose, I need to execute a shell command, achieve the output, and for each line ask user for prompt. The problem is that on the read prompt, stdin buffer isn't empty
this is my code:
#!/bin/sh
git branch -a | sed 's/remotes\/origin\///g'
echo "############################"
git branch -a | sed 's/remotes\/origin\///g' | while read line
do
if [[ "$line" != *develop* ]] \
&& [[ "$line" != *master ]] \
&& [[ "$line" != *release/* ]] \
&& [[ "$line" != *hotfix* ]]
then
read -r -p "Do you want to delete branch $line <y/N>?" prompt
echo $prompt
fi
done
The line:
read -r -p "Do you want to delete branch $line <y/N>?" prompt
does not even display to video, and prompt variable show the result of line variable above. How can I solve this problem?