###--------------------------------------------------------------------------
### Processing the results.
+proc build-command {command args} {
+ ## Return the COMMAND list, after applying the string map ARGS to each item
+ ## in turn.
+
+ set cmd {}
+ foreach item $command {
+ lappend cmd [string map $args $item]
+ }
+ return $cmd
+}
+
proc zone-file-name {view config} {
## Return the relative file name for the zone described by CONFIG, relative
## to the given VIEW. An absolute filename may be derived later, depending
}
close $chan
- set cmd {}
- foreach item $zone(checkzone-command) {
- lappend cmd [string map [list \
- "%z" $name \
- "%v" $view \
- "%f" $tmp] \
- $item]
- }
+ ## Check the zone for sanity.
+ set cmd [build-command $zone(checkzone-command) \
+ "%z" $name \
+ "%v" $view \
+ "%f" $tmp]
set rc [catch {
set out [eval exec $cmd]
} msg]
file rename -force -- $tmp $zone(file-name)
set cleanup {}
foreach view $matchview {
- set cmd {}
- foreach item $zone(reload-command) {
- lappend cmd [string map [list \
- "%v" $view \
- "%z" $zone(name)] \
- $item]
- }
- eval exec $cmd
+ eval exec $cmd [build-command $zone(reload-command) \
+ "%v" $view \
+ "%z" $zone(name)]
}
} {
eval $cleanup