From: Enrico Scholz Date: Mon, 25 Jul 2005 15:39:01 +0000 (+0000) Subject: isDirectoryEmpty(): added X-Git-Tag: version_0_30_210~120 X-Git-Url: http://git.linux-vserver.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=2edfce6caccd0c8941464813245991add9ab0786;p=util-vserver.git isDirectoryEmpty(): added col*(): added git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2161 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- diff --git a/util-vserver/scripts/functions b/util-vserver/scripts/functions index cd6a955..4b8e4c8 100644 --- a/util-vserver/scripts/functions +++ b/util-vserver/scripts/functions @@ -84,6 +84,29 @@ function getPhysicalDir ( set -P && cd "$1" && pwd ) } +## Usage:: isDirectoryEmpty [] +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 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 function xtermTitle {