From 8aae06a4b20b1638237e4a5442a26ebb3fe6a3b1 Mon Sep 17 00:00:00 2001 From: framp Date: Sat, 24 Mar 2018 12:01:59 +0100 Subject: [PATCH] Modified cleanup --- pishrink.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/pishrink.sh b/pishrink.sh index 4cbc518..1d68900 100755 --- a/pishrink.sh +++ b/pishrink.sh @@ -1,7 +1,9 @@ #!/bin/bash function cleanup() { - [[ -n $loopback ]] && losetup -d "$loopback" + if losetup $loopback &>/dev/null; then + losetup -d "$loopback" + fi } usage() { echo "Usage: $0 [-s] imagefile.img [newimagefile.img]"; exit -1; }