I am creating automatic plugin update function using bash and wp cli command.Using bash script i have checking update available plugins and storing those plugin names in a text file. Now i want to update plugin one by one by reading the plugin name from text file i created. When reading plugin name from text file i want to display "Do you want to update ? Y/N " command on terminal. If user submit yes then update first plugin else show "Do you want to update ? Y/N " command for second plugin.
I have written code for that but its not working. Its not displaying "Do you want to update ? Y/N " on terminal. I added that code inside the while loop of bash script.
How can i display "Do you want to update ? Y/N " on terminal by using while loop in bash script ??? Then i want to update plugin based on user input is equal to Y. if user input is N then dont update that plugin.
Following are my code its not working now.
read -p "Do you want to list Plugin updates for $user ? Y/N " -n 1 -r
echo
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
# Display the list of plugins
wp plugin list --update=available
wp plugin list --update=available --field=name > plugins.txt
while read p; do
read -p "Do you want Plugin updates for $p ? Y/N " -n 1 -r
if [[ $REPLY =~ ^[Yy]$ ]]
then
echo
wp plugin update $p
fi
done <plugins.txt
fi
echo "-----------------------------------------------------------"
echo "Finished!"