From 2edfce6caccd0c8941464813245991add9ab0786 Mon Sep 17 00:00:00 2001 From: Enrico Scholz Date: Mon, 25 Jul 2005 15:39:01 +0000 Subject: [PATCH] isDirectoryEmpty(): added col*(): added git-svn-id: http://svn.linux-vserver.org/svn/util-vserver/trunk@2161 94cd875c-1c1d-0410-91d2-eb244daf1a30 --- util-vserver/scripts/functions | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) 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 { -- 1.8.1.5