From 0f4fbe00108c811da20e802290d9d50fc8daff4d Mon Sep 17 00:00:00 2001 From: Craig Jennings Date: Mon, 13 Apr 2026 00:12:18 -0400 Subject: refactor: dedupe findmnt invocation in safe_cleanup_work_dir MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The catch-all mount-cleanup block called findmnt twice (once as an existence guard, once in the pipe). Consolidate to a single call captured to a local, guard with -n test. No behavior change — same mounts, same order, same lazy-unmount. Left the explicit known-mount loop alone; it's a faster path for the deterministic mkarchiso bind mounts, with findmnt as the catch-all for anything else. Not parallel strategies, just fast path + fallback. --- build.sh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'build.sh') diff --git a/build.sh b/build.sh index c494ef7..6144932 100755 --- a/build.sh +++ b/build.sh @@ -48,11 +48,15 @@ safe_cleanup_work_dir() { fi done - # Also catch any other mounts we might have missed - if findmnt --list -o TARGET 2>/dev/null | grep -q "$airootfs"; then - findmnt --list -o TARGET 2>/dev/null | grep "$airootfs" | sort -r | while read -r mp; do + # Catch any other mounts under airootfs (bind mounts not in the + # explicit list above). Deepest-first via reverse sort. + local leftover + leftover=$(findmnt --list --noheadings -o TARGET 2>/dev/null \ + | grep "$airootfs" | sort -r) + if [[ -n "$leftover" ]]; then + while IFS= read -r mp; do umount -l "$mp" 2>/dev/null || true - done + done <<< "$leftover" fi # Small delay to let lazy unmounts complete -- cgit v1.2.3