Skip to content
Snippets Groups Projects
Commit 5a2c762e authored by ale's avatar ale
Browse files

make detach_img idempotent

parent ceae320d
No related branches found
No related tags found
No related merge requests found
......@@ -99,8 +99,20 @@ attach_img() {
fi
}
is_mounted() {
local mountpoint="$1"
local mountpoint_abs="$(cd "${mountpoint}" && pwd)"
local tmp=$(mount | awk "\$1 == \"${mountpoint_abs}\"")
if [ -z "${tmp}" ]; then
return 1
else
return 0
fi
}
detach_img() {
local mountpoint="$1"
is_mounted "${mountpoint}" || return 0
case ${OS} in
Darwin)
sudo hdiutil detach "${mountpoint}"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment