Fix bootstrap to work with bash 4.3

Signed-off-by: Alexey Neyman <stilor@att.net>
This commit is contained in:
Alexey Neyman 2017-07-06 18:20:44 -07:00
parent 4000e1def3
commit 4bd6d5f560

View File

@ -99,17 +99,29 @@ run_if()
do_foreach() do_foreach()
{ {
local var="${1}" local var="${1}"
local v saveinfo local -A saveinfo
local v k
shift shift
if [ "`type -t enter_${var}`" != "function" ]; then if [ "`type -t enter_${var}`" != "function" ]; then
error "No parameter setup routine for iterator over '${var}'" error "No parameter setup routine for iterator over '${var}'"
fi fi
for v in ${info[iter_${var}]}; do for v in ${info[iter_${var}]}; do
saveinfo=`declare -p info` # This works in bash 4.4, but not in bash 4.3:
# local saveinfo=`declare -p info`
# ...
# eval "${saveinfo}"
# Therefore, need to save key-by-key
saveinfo=()
for k in "${!info[@]}"; do
saveinfo["${k}"]=${info["${k}"]}
done
eval "enter_${var} ${v}" eval "enter_${var} ${v}"
eval "$@" eval "$@"
eval "${saveinfo#declare -A }" info=()
for k in "${!saveinfo[@]}"; do
info["${k}"]=${saveinfo["${k}"]}
done
done done
} }