In the script below - which prompts the user to confirm that they want to proceed with running a potentially bad script - when the user enters Y at the prompt - it will break out of the case block, only to be sent back into the while loop again.
#! /bin/bash
set -e
echo
echo "bad install start"
echo "-----------------------------------------"
while true; do
read -p "this script will probably fail - do you want to run anyway?" yn
case $yn in
[Yy]*)
##### WHAT GOES HERE?? #####
;;
[Nn]*)
exit ;;
*)
echo "answer y or n" ;;
esac
echo "script has broken out of case back into while loop"
done
echo -e "\e[33m Installing bad packagename \e[0m"
apt-get install sdfsdfdfsd
echo "rest of script - will i keep running?"
When n is entered, the script exists entirely as desired. I'd like to know how to make it so that when Y is entered the script breaks out of both the case and the while block, but does not exit entirely. Is there something I can put in for the placeholder ("What goes here??") to do that?
[Yn]*); you probably meant[Yy]*).$TEST=1should beTEST=1, and your script is very likely to work with this change.