Fix shell 'eval' metacharacter bug in test defs

This commit is contained in:
Andrew Bettison 2012-10-09 14:03:59 +10:30
parent 3433b0fbb5
commit aca4e8eda9
2 changed files with 8 additions and 8 deletions

View File

@ -61,7 +61,7 @@ extract_stdout_keyvalue_optional() {
_value="${_line#*$_delim}"
_return=0
fi
[ -n "$_var" ] && eval $_var="$_value"
[ -n "$_var" ] && eval $_var="\$_value"
return $_return
}
@ -342,11 +342,11 @@ get_servald_server_pidfile() {
set_instance_fromarg "$1" && shift
local _pidfile="$instance_servald_pidfile"
pop_instance
[ -n "$_pidfilevar" ] && eval $_pidfilevar="$_pidfile"
[ -n "$_pidfilevar" ] && eval $_pidfilevar="\$_pidfile"
local _pid=$(cat "$_pidfile" 2>/dev/null)
case "$_pid" in
+([0-9]))
[ -n "$_pidvar" ] && eval $_pidvar="$_pid"
[ -n "$_pidvar" ] && eval $_pidvar="\$_pid"
return 0
;;
'')
@ -449,7 +449,7 @@ get_servald_pids() {
local mypid=$$
# XXX The following line will not find any PIDs if there are spaces in "$servald".
local pids=$(ps -u$UID -o pid,args | $AWK -v mypid="$mypid" -v servald="$servald" '$1 != mypid && $2 == servald {print $1}')
[ -n "$var" ] && eval "$var=($pids)"
[ -n "$var" ] && eval "$var=(\$pids)"
[ -n "$pids" ]
}
@ -599,8 +599,8 @@ start_servald_instances() {
executeOk_servald config set mdp.socket "org.servalproject.servald.mdp.socket.$TFWUNIQUE.$instance_name"
configure_servald_server
start_servald_server
eval DUMMY$instance_name="$DUMMYNET"
eval LOG$instance_name="$(shellarg "$instance_servald_log")"
eval DUMMY$instance_name="\$DUMMYNET"
eval LOG$instance_name="\$(shellarg "\$instance_servald_log")"
done
# Now wait until they see each other.
wait_until --sleep=0.25 instances_see_each_other "$@"

View File

@ -179,7 +179,7 @@ extract_manifest() {
assert --message="$_manifestfile contains valid '$_label=' line" \
--dump-on-fail="$_manifestfile" \
[ -n "$_value" ]
[ -n "$_var" ] && eval $_var="$_value"
[ -n "$_var" ] && eval $_var="\$_value"
}
extract_manifest_service() {
@ -216,7 +216,7 @@ compute_filehash() {
local _hash=$($servald rhizome hash file "$_file") || error "$servald failed to compute file hash"
[ -z "${_hash//[0-9a-fA-F]/}" ] || error "file hash contains non-hex: $_hash"
[ "${#_hash}" -eq 128 ] || error "file hash incorrect length: $_hash"
[ -n "$_var" ] && eval $_var="$_hash"
[ -n "$_var" ] && eval $_var="\$_hash"
}
rhizome_http_server_started() {