[Fai-commit] r6728 - in trunk: lib man

Thomas Lange lange at alioth.debian.org
Sat Oct 22 16:02:22 UTC 2011


Author: lange
Date: 2011-10-22 16:02:22 +0000 (Sat, 22 Oct 2011)
New Revision: 6728

Modified:
   trunk/lib/subroutines
   trunk/man/fai-class.1
Log:
use bash regex matching instead of associative array

_ifclass implementation using associative arrays does not work at all
because bash can't export arrays and assoziative arrays to the
subshell
removed variable hclasses


Modified: trunk/lib/subroutines
===================================================================
--- trunk/lib/subroutines	2011-10-22 16:01:28 UTC (rev 6727)
+++ trunk/lib/subroutines	2011-10-22 16:02:22 UTC (rev 6728)
@@ -81,11 +81,7 @@
     # test if a class is defined
     local ret
 
-    if [ "${#hclasses[@]}" = 0 ]; then
-	echo "ifclass: WARNING. Associative array hclasses is empty." >&2
-    fi
-
-    if [ X${hclasses[$1]} = X1 ]; then
+    if [[ "$classes" =~ (^|[[:space:]]+)$1($|[[:space:]]+) ]]; then
 	ret=0
     else
     	ret=1
@@ -369,7 +365,7 @@
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 ### BEGIN SUBROUTINE INFO
-# Provides-Var:    $classes $hclasses $cfclasses
+# Provides-Var:    $classes $cfclasses
 # Requires-Var:    $LOGDIR
 # Suggests-Var:    $renewclass
 # Short-Description: define FAI classes and store them in several shell variables
@@ -405,8 +401,6 @@
     cfclasses=${cfclasses// /.}
     [ "$debug" ] && echo "cfclasses: $cfclasses"
     # define a bash hash with all class names. Without this, ifclass does not work
-    declare -A hclasses
-    for c in $classes; do hclasses[$c]=1;done
 }
 # - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
 _defvar() {

Modified: trunk/man/fai-class.1
===================================================================
--- trunk/man/fai-class.1	2011-10-22 16:01:28 UTC (rev 6727)
+++ trunk/man/fai-class.1	2011-10-22 16:02:22 UTC (rev 6728)
@@ -82,13 +82,9 @@
 
    # fai\-class /fai/class /tmp/fai/FAI_CLASSES
 
-Then the list of all classes is assigned to the variable classes. The
-associative array variable hclasses contains a hash with every class
-name as index.
+Then the list of all classes is assigned to the variable classes.
 
     classes=`cat /tmp/fai/FAI_CLASSES`
-    declare -A hclasses
-    for c in $classes; do hclasses[$c]=1;done
 
 .SH "EXAMPLES FOR SCRIPTS"
 .ta 40n




More information about the Fai-commit mailing list