Improved user input

It doesn't exit in case of a invalid input, asks again
Make the allowed input uniform
pull/16/head
Samega7Cattac 2 years ago
parent 60caf0637c
commit 16b46b7dcf
No known key found for this signature in database
GPG Key ID: D084C57D85D7477B

@ -92,18 +92,18 @@ echo "for example enter sda or sdb"
read letter read letter
drive=/dev/$letter drive=/dev/$letter
drive2="$drive""1" drive2="$drive""1"
echo "You want to install Ventoy and Medicat to $drive / $drive2?" checkingconfirm=""
echo "Please enter Y or N" while [[ "$checkingconfirm" != [NnYy]* ]]; do
read checkingconfirm read -e -p "You want to install Ventoy and Medicat to $drive / $drive2? (Y/N) " checkingconfirm
if [ $checkingconfirm = "N" ]; then if [[ "$checkingconfirm" == [Nn]* ]]; then
exit exit
elif [ $checkingconfirm = "Y" ]; then elif [[ "$checkingconfirm" == [Yy]* ]]; then
echo "Okay! Will continue in 5 seconds!" echo "Okay! Will continue in 5 seconds!"
sleep 5 sleep 5
else else
echo "The only valid options are Y or N" echo "Invalid input!"
exit fi
fi done
sudo sh ./ventoy/Ventoy2Disk.sh -I $drive sudo sh ./ventoy/Ventoy2Disk.sh -I $drive
umount $drive umount $drive
@ -114,13 +114,15 @@ fi
sudo mount $drive2 ./MedicatUSB sudo mount $drive2 ./MedicatUSB
7z x -O./MedicatUSB "$location" 7z x -O./MedicatUSB "$location"
echo "MedicatUSB has been created!" echo "MedicatUSB has been created!"
echo "Would you like to unmount ./MedicatUSB? (Y/N)" unmountcheck=""
read unmountcheck while [[ "$unmountcheck" != [NnYy]* ]]; do
if [ $unmountcheck = "Y" ]; then read -e -p "Would you like to unmount ./MedicatUSB? (Y/N) " unmountcheck
echo "MedicatUSB will be unmounted!" if [[ $unmountcheck == [Yy]* ]]; then
sudo umount ./MedicatUSB echo "MedicatUSB will be unmounted!"
elif [ $unmountcheck = "N" ]; then sudo umount ./MedicatUSB
echo "MedicatUSB will not be unmounted!" elif [[ $unmountcheck == [Nn]* ]]; then
else echo "MedicatUSB will not be unmounted!"
"The only valid options are Y or N" else
fi echo "Invalid input!"
fi
done

Loading…
Cancel
Save