* isRegularFile(): fixed evaluation of params
authorEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 28 Apr 2005 18:02:27 +0000 (18:02 +0000)
committerEnrico Scholz <enrico.scholz@informatik.tu-chemnitz.de>
Thu, 28 Apr 2005 18:02:27 +0000 (18:02 +0000)
* hasSubstring():   added
* getAllVservers(): fixed typo

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

util-vserver/scripts/functions

index 017bb07..009bcc1 100644 (file)
@@ -70,9 +70,9 @@ function findAndCopy
 ## Usage: isRegularFile <filename> [<mod>]
 function isRegularFile
 {
-    test ${mod:--f} "$1" || return 1
+    test ${2:--f} "$1" || return 1
 
-    case $file in
+    case $1 in
        (*.rpmsave|*.rpmnew|*.rpmorig|*.cfsaved*|*.~*~) return 1;;
     esac
 
@@ -140,6 +140,22 @@ function isNumber
     return 0
 }
 
+## Usage: hasSubstring <haystack> <needle>+
+function hasSubstring
+{
+    local pat=$1
+    local i
+    
+    shift
+
+    for i; do
+       test x"${pat/*$i*/$i}" = x"$i" || continue
+       return 0
+    done
+
+    return 1
+}
+
 ## Usage: colorize <style> <command>
 function colorize
 {
@@ -436,8 +452,8 @@ function getAllVservers
        case ${2:-ALL} in
            (MARKED)    test   -s "$_ga_markfile" || _ga_doadd=;;
            (UNMARKED)  test ! -s "$_ga_markfile" || _ga_doadd=;;
-           (STOPPED)   ! $_VSERVER "$_ga_i" runnning &>/dev/null || _ga_doadd=;;
-           (RUNNING)     $_VSERVER "$_ga_i" runnning &>/dev/null || _ga_doadd=;;
+           (STOPPED)   ! $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
+           (RUNNING)     $_VSERVER "$_ga_i" running &>/dev/null || _ga_doadd=;;
            (ALL)       ;;
            (*)         panic $"Unknown vserver tagging '$2'";;
        esac