# # gen_v1 # ------ # # generate variables with one number marked as # # parameters: # $1 start index (1 or 2) # $2 maximum number of elements to generate # if examples are generated this value is greater # than the number contained in the master variable # $3 name of master variable # $4.. names of dependent variables # gen_v1() { start=$1 shift lto=$1 shift iname=$1 shift names=$* # check highest index eval [ "\$${iname}" -gt $lto ] && eval lto=\$${iname} eval [ "\$OLD_${iname}" -gt $lto ] && eval lto=\$OLD_${iname} idx=$start while [ $idx -le $lto ] do for name in $names do vname=`echo $name | sed "s|#|$idx|"` eval val=\${OLD_$vname:=\$$vname} echo "$vname='$val'" done idx=`expr $idx + 1` done } update_config() { # 1. Step prepare old configuration for sourcing # remove leading spaces and tabs # use only lines starting with capital letters # precede each name with OLD_ cat ${OLD_CONFIG} | \ sed 's|^[[:blank:]]*||' | \ grep '^[A-Z]' | \ sed 's|^.*|OLD_&|' > ${OLD_CONFIG}.old # 2. Step source the file . ${OLD_CONFIG}.old # 3. Step remove the file rm -f ${OLD_CONFIG}.old # 4. Step source the package configuration if [ ! -f ${PKG_CONFIG} ]; then mecho -error "internal error: ${PKG_CONFIG} does not exist" exit 1 else . ${PKG_CONFIG} fi # 5. clear configuration file > $NEW_CONFIG # 6. Step generate the new configuration (