From 956cfd7325c52ac95c83c3d3a45e78066103857a Mon Sep 17 00:00:00 2001 From: MatMoul Date: Mon, 27 Apr 2026 23:40:28 +0200 Subject: [PATCH] fix: tighten mtm-ddwipe usage and device checks Add an explicit mounted-device check with findmnt, shorten confirmation prompts, and align the usage text and log wording with the current script name. --- .continue/rules/project.md | 2 +- mtm-ddwipe | 16 +++++++++------- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/.continue/rules/project.md b/.continue/rules/project.md index a6511d5..247eee0 100644 --- a/.continue/rules/project.md +++ b/.continue/rules/project.md @@ -14,7 +14,7 @@ description: mtm-ddwipe project conventions - Keep user-facing messages short and clear. - Keep error and help messages short and clear. - Prefer minimal, focused changes that preserve intent. -- Keep `.continue/rules/project.md` aligned with project conventions and concise. +- Keep `.continue/rules/project.md` aligned and concise. - `mtm-ddwipe` is a small Bash script with helper functions. - Keep the host and line-number removal behavior intact for related output processing. - `mtm-ddwipe` must print a usage line and support `-h`/`--help`. diff --git a/mtm-ddwipe b/mtm-ddwipe index 54fe4fb..bfef696 100644 --- a/mtm-ddwipe +++ b/mtm-ddwipe @@ -8,7 +8,7 @@ STARTDATESTRING="" usage() { cat </dev/null 2>&1; then + die "Device is mounted: $dev" + fi + if lsblk -nrpo NAME,MOUNTPOINT "$dev" | awk '$2 != "" { found=1 } END { exit !found }'; then - die "Device or one of its children is mounted: $dev" + die "Device or child is mounted: $dev" fi } @@ -67,13 +71,11 @@ confirm_wipe() { local dev="$1" local choice="" - echo "Selected device:" + echo "Device:" lsblk -o NAME,SIZE,TYPE,FSTYPE,MOUNTPOINT,MODEL,SERIAL "$dev" echo "" - echo "This will destroy data on: $dev" echo "Type exactly: WIPE $dev" - echo "" - read -r -p "Confirmation: " choice + read -r -p "Confirm: " choice [ "$choice" = "WIPE $dev" ] || die "Canceled" echo "" } @@ -143,7 +145,7 @@ wipe_dev() { STARTDATE=$(date +%s) STARTDATESTRING="$(date)" - log "Begin wiping device $dev" + log "Begin wiping: $dev" echo "" log "Start date :" log "$STARTDATESTRING"