From: Mike Frysinger Date: Tue, 12 Jun 2012 14:17:00 +0000 (-0400) Subject: use /proc/mounts for better checking X-Git-Url: https://git.wh0rd.org/?a=commitdiff_plain;h=b0a310486d7bd4af95c3b54ddce582790f9c87c6;p=home.git use /proc/mounts for better checking --- diff --git a/.bin/umount-tree b/.bin/umount-tree index bcf866f..340b61a 100755 --- a/.bin/umount-tree +++ b/.bin/umount-tree @@ -1,17 +1,21 @@ #!/bin/bash -root=$1 if [[ -z $1 ]] ; then echo "Usage: $0 " exit 1 fi -mounts=$(mount | grep " on ${root%/}/" | awk '{print $3}' | tac) +while [[ $# -gt 0 ]] ; do + +root=$1 +shift + +mounts=$(gawk -v p="${root%/}" '$2 ~ "^"p { print $2 }' /proc/mounts | tac) if [[ -z ${mounts} ]] ; then echo "No mounts found ..." echo mount - exit 0 + continue fi echo "Unmounting: " @@ -20,3 +24,5 @@ printf '\t%s\n' ${mounts} printf "OK? [y/N] " read v [[ ${v} == "y" ]] && sudo umount -v ${mounts} + +done