run: use 'upvar' instead of 'global'

Using 'upvar' instead of 'global' in the 'append_if' and 'lappend_if'
functions makes it possible to use these functions with local variables
of the calling function.

Fixes #1137.
This commit is contained in:
Christian Prochaska 2014-04-07 19:47:31 +02:00 committed by Norman Feske
parent e777165090
commit b28a551538
1 changed files with 4 additions and 4 deletions

View File

@ -69,8 +69,8 @@ proc create_boot_directory { } { }
# Append string to variable only if 'condition' is satisfied
#
proc append_if {condition var string} {
global $var
if {$condition} { append $var $string }
upvar $var up_var
if {$condition} { append up_var $string }
}
@ -78,8 +78,8 @@ proc append_if {condition var string} {
# Append element to list only if 'condition' is satisfied
#
proc lappend_if {condition var string} {
global $var
if {$condition} { lappend $var $string }
upvar $var up_var
if {$condition} { lappend up_var $string }
}