Technical data

8. Documentation for Developers
Match-Operator
With the match operator =~ you can check whether a regular expression matches the value of a
variable. Furthermore, one can also use the operator to extract subexpressions from a variable.
After successfully applying a regular expression on a variable the array MATCH_% contains the
parts found. May look like this:
set foo="foobar12"
if ( foo =~ "(foo)(bar)([0-9]*)" )
then
foreach i in match_%
do
warning "match %i: $i"
done
fi
Calling mkfli4l then would lead to this output:
Warning: match MATCH_1: foo
Warning: match MATCH_2: bar
Warning: match MATCH_3: 12
When using =~ you may take all existing regular expressions into account. If you i.e. want
to check whether a PCMCIA Ethernet driver is selected without OPT_PCMCIA being set to “yes”,
it might look like this:
if (!opt_pcmcia)
then
foreach i in net_drv_%
do
if (i =~ "^(RE:PCMCIA_NET_DRV)$")
then
error "If you want to use ..."
fi
done
fi
As demonstrated in the example, it is important to anchor the regular expression with ˆ
and $ if intending to apply the expression on the complete variable. Otherwise, the match-
expression already returns “true” if only a part of the variable is covered by the regular ex-
pression, which is certainly not desired in this case.
Check if a File has been copied depending on the Value of a Variable: copy_pending
With the information gained during the checking process the function copy_pending tests
if a file has been copied depending on the value of a variable or not. This can be used i.e.
in order to test whether the driver specified by the user really exists and has been copied.
copy_pending accepts the name to be tested in the form of a variable or a string.
5
In order
to accomplish this copy_pending checks whether
5
As described before the string is subject of variable substitution, i.e via a foreach-loop (Page 309) and a
%<Name>-subsitution (Page 300) all elements of an array may be examined.
312