fix use of `eend` in `cleanup` function
[grml-debootstrap.git] / grml-debootstrap
index 2124614..4758bce 100755 (executable)
@@ -244,11 +244,11 @@ check4progs(){
 # helper functions {{{
 cleanup() {
   if [ -n "$CHROOT_VARIABLES" ] ; then
-    einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" ; eend $?
+    einfo "Removing ${CHROOT_VARIABLES}" ; rm "$CHROOT_VARIABLES" || eend $?
   fi
 
   if [ -n "$STAGES" ] ; then
-    einfo "Removing ${STAGES}" ; rmdir "$STAGES" ; eend $?
+    einfo "Removing ${STAGES}" ; rmdir "$STAGES" || eend $?
   fi
 
   if [ -n "$ARM_EFI_TARGET" ]; then
@@ -258,7 +258,7 @@ cleanup() {
   # Remove temporary mountpoint again
   if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
     if [ -d "$MNTPOINT" ] ; then
-      rmdir "$MNTPOINT" 2>/dev/null
+      rmdir "$MNTPOINT"
     fi
   fi
 
@@ -299,8 +299,10 @@ cleanup() {
 
       # remove directory only if we used the default with process id inside the name
       if echo "$MNTPOINT" | grep -q '/mnt/debootstrap\.' ; then
-        einfo "Removing directory ${MNTPOINT}"
-        rmdir "$MNTPOINT" || eend $?
+        if test -d "$MNTPOINT" ; then
+          einfo "Removing directory ${MNTPOINT}"
+          rmdir "$MNTPOINT" || eend $?
+        fi
       fi
     fi
   fi