Defer wipe until after final confirmation

Move the partition wipe to after user types 'yes' so they can
still abort without having already wiped the device.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Aaron D. Lee
2026-01-08 11:21:41 -05:00
parent 3e2307cbcf
commit ddee3583e8

View File

@@ -249,16 +249,9 @@ if [ -n "$MOUNTED" ]; then
done done
fi fi
# Ask about wiping # Ask about wiping (defer actual wipe until after final confirmation)
echo echo
read -p "Wipe partition table first? (recommended if having issues) [y/N] " wipe_confirm read -p "Wipe partition table first? (recommended if having issues) [y/N] " wipe_confirm
if [[ "$wipe_confirm" =~ ^[Yy]$ ]]; then
echo "Wiping partition table..."
sudo wipefs -a "$SELECTED"
sudo dd if=/dev/zero of="$SELECTED" bs=1M count=10 status=none
sync
echo " Wiped clean"
fi
# Final confirmation # Final confirmation
echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}" echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}"
@@ -272,6 +265,15 @@ if [[ ! $REPLY == "yes" ]]; then
exit 1 exit 1
fi fi
# Now wipe if requested
if [[ "$wipe_confirm" =~ ^[Yy]$ ]]; then
echo "Wiping partition table..."
sudo wipefs -a "$SELECTED"
sudo dd if=/dev/zero of="$SELECTED" bs=1M count=10 status=none
sync
echo " Wiped clean"
fi
echo "" echo ""
echo -e "${GREEN}Flashing image to $SELECTED...${NC}" echo -e "${GREEN}Flashing image to $SELECTED...${NC}"
echo "" echo ""