isDirectoryEmpty(): added
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 25 Jul 2005 15:39:01 +0000 (15:39 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Mon, 25 Jul 2005 15:39:01 +0000 (15:39 +0000)
col*(): added

git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2161 94cd875c-1c1d-0410-91d2-eb244daf1a30

util-vserver/scripts/functions

index cd6a955..4b8e4c8 100644 (file)
@@ -84,6 +84,29 @@ function getPhysicalDir
     ( set -P && cd "$1" && pwd )
 }
 
+## Usage:: isDirectoryEmpty <dir> [<ignore-lost+found>]
+function isDirectoryEmpty
+{
+    (
+       shopt -s dotglob  || *
+       shopt -s nullglob || *
+
+       ignore_lostfound=1
+       test -z "$2" -o "$2" = 0 || ignore_lostfound=
+       
+       for i in "$1"/*; do
+           case "$i" in
+               (lost+found)
+                   test "$ignore_lostfound" || exit 1
+                   ;;
+               (*)     echo "$i"; exit 1
+           esac
+        done
+
+       exit 0
+    )
+}
+
 ## Usage: logging <message>
 function logging
 {
@@ -185,6 +208,22 @@ function colorize
     fi
 }
 
+function colpanic
+{
+    colorize error   panic     "$@"
+}
+
+function colwarning
+{
+    colorize warning warning "$@"
+}
+
+function colinfo
+{
+    colorize info    echo "$@"
+}
+
+
 ## Usage: xtermTitle <title>
 function xtermTitle
 {