diff --git a/format-buddy.sh b/format-buddy.sh index 8eada66..eae36b8 100755 --- a/format-buddy.sh +++ b/format-buddy.sh @@ -1,30 +1,48 @@ #!/bin/bash -while [ 1=1 ];do +while true; do clear echo "[1] - Format device as Fat32" + echo "[2] - Exit" echo echo -n ">>: " read choice - if [ "$choice" = "1" ];then + if [ "${choice}" = "1" ];then echo lsblk echo echo -n "Type full path to device (/dev/xx1): " read device - mkfs.fat -F32 -v -l -n $device - - - - + if [[ ! "${device}" =~ ^/dev/[a-z]+[0-9]*$ ]]; then + echo "Error: Invalid device path" + read -n 1 -p "Press any key..." + continue + fi + + echo "WARNING: This will destroy ALL data on ${device}" + echo -n "Type 'YES' to confirm: " + read confirm + + if [ "${confirm}" != "YES" ]; then + echo "Aborted." + read -n 1 -p "Press any key..." + continue + fi + + mkfs.fat -F32 -v -n "FAT32" "${device}" + echo "Format complete." + read -n 1 -p "Press any key..." + elif [ "${choice}" = "2" ];then + break else - echo "Fuck....." + echo "Invalid option" + read -n 1 -p "Press any key..." fi done