chiark
/
gitweb
/
~mdw
/
zoneconf
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
bin/zoneconf: Abstract out command substitution machinery.
[zoneconf]
/
bin
/
zoneconf
diff --git
a/bin/zoneconf
b/bin/zoneconf
index 820f62f473322ab2f84e0e6ccf10c551a4e9b159..7ee6d6ab1c655377005ee683b7963eebfb709bb0 100755
(executable)
--- a/
bin/zoneconf
+++ b/
bin/zoneconf
@@
-1037,6
+1037,17
@@
define-configuration-space toplevel ZONECFG {
###--------------------------------------------------------------------------
### Processing the results.
###--------------------------------------------------------------------------
### 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
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
@@
-1297,14
+1308,11
@@
provided by the named USER"
}
close $chan
}
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]
set rc [catch {
set out [eval exec $cmd]
} msg]
@@
-1322,14
+1330,9
@@
provided by the named USER"
file rename -force -- $tmp $zone(file-name)
set cleanup {}
foreach view $matchview {
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
}
} {
eval $cleanup