From ddee3583e8ec57513a6e55ba0dced4416c096553 Mon Sep 17 00:00:00 2001 From: "Aaron D. Lee" Date: Thu, 8 Jan 2026 11:21:41 -0500 Subject: [PATCH] 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 --- rpi/flash-image.sh | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/rpi/flash-image.sh b/rpi/flash-image.sh index 1dffea4..2c3eb9c 100755 --- a/rpi/flash-image.sh +++ b/rpi/flash-image.sh @@ -249,16 +249,9 @@ if [ -n "$MOUNTED" ]; then done fi -# Ask about wiping +# Ask about wiping (defer actual wipe until after final confirmation) echo 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 echo -e "${RED}╔═══════════════════════════════════════════════════════════════╗${NC}" @@ -272,6 +265,15 @@ if [[ ! $REPLY == "yes" ]]; then exit 1 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 -e "${GREEN}Flashing image to $SELECTED...${NC}" echo ""