]> sourceware.org Git - lvm2.git/commitdiff
lvmdump: Allow dir to exist already if it is empty
authorAlasdair G Kergon <agk@redhat.com>
Wed, 6 Apr 2016 21:36:42 +0000 (22:36 +0100)
committerAlasdair G Kergon <agk@redhat.com>
Wed, 6 Apr 2016 21:36:42 +0000 (22:36 +0100)
WHATS_NEW
scripts/lvmdump.sh

index 98168a16ddc18f1387dbbace760120c89b63b978..b1da1b0dbc7057bdaf0864f8dcadf239cfba9dfb 100644 (file)
--- a/WHATS_NEW
+++ b/WHATS_NEW
@@ -1,5 +1,6 @@
 Version 2.02.150 -
 =================================
+  Allow the lvmdump directory to exist already provided it is empty.
 
 Version 2.02.149 - 1st April 2016
 =================================
index 1e91a9d005feb55383699a787d9dac6e6a24004e..19b36d37edae445934a9c05a8054d69437c2b08a 100755 (executable)
@@ -99,8 +99,12 @@ else
        dir="$HOME/$dirbase"
 fi
 
-test -e $dir && die 3 "Fatal: $dir already exists"
-$MKDIR -p $dir || die 4 "Fatal: could not create $dir"
+if test -d $dir ; then
+       (shopt -s nullglob dotglob; cd $dir && files=(*) && ((${#files[@]}))) && die 5 "Fatal: directory $dir already exists and is not empty"
+else
+       test -e $dir && die 3 "Fatal: $dir already exists"
+       $MKDIR -p $dir || die 4 "Fatal: could not create $dir"
+fi
 
 log="$dir/lvmdump.log"
 
This page took 0.086649 seconds and 5 git commands to generate.