Technical data
8. Documentation for Developers
set s="a"
set v1="$s" # v1="a"
set s="b"
set v2="$s" # v2="b"
if (v1 == v2)
then
warning "equal"
else
warning "not equal"
fi
will output “not equal”, because the variables v1 and v2 replace the content of the variable
s already at the time of assignment.
Hint: A variable set in a script is visible while processing further scripts – currently there
exists no such thing as local variables. Since the order of processing scripts of different packages
is not defined, you should never rely on any variable having values defined by another package.
Arrays
If you want to access elements of a %-variable (of an array) you have to use the original name
of the variable like mentioned in the file check/<PACKAGE>.txt and add an index for each “%”
sign by using “[Index]”.
Example: If you want to access the elements of variable PF_USR_CHAIN_%_RULE_% you need
two indices because the variable has two “%” signs. All elements may be printed for example
using the following code (the foreach-loop is exlained in see below (Page 309)):
foreach i in pf_usr_chain_n
do
# only one index needed, only one '%' in the variable's name
set j_n=pf_usr_chain_%_rule_n[i]
# Attention: a
# foreach j in pf_usr_chain_%_rule_n[i]
# is not possible, hence the use of j_n!
foreach j in j_n
do
# two indices needed, two '%' in the variable's name
set rule=pf_usr_chain_%_rule_%[i][j]
warning "Rule $i/$j: ${rule}"
done
done
With this sample configuration
PF_USR_CHAIN_N='2'
PF_USR_CHAIN_1_NAME='usr-chain_a'
PF_USR_CHAIN_1_RULE_N='2'
PF_USR_CHAIN_1_RULE_1='ACCEPT'
PF_USR_CHAIN_1_RULE_2='REJECT'
PF_USR_CHAIN_2_NAME='usr-chain_b'
PF_USR_CHAIN_2_RULE_N='1'
PF_USR_CHAIN_2_RULE_1='DROP'
304










