Skip to content

Commit

Permalink
Fix indirect var names (#9)
Browse files Browse the repository at this point in the history
* First look at implementing self testing 👍

* Update Travis lang to be generic

* Fix Travis permdied error

* Try to fix Travis build

* Try to remove cp Travis command

* input path fixes + more tests 🚀

* Update readme

* Fixing invalid indirect names

* Fix [@] arrays problems 👍
  • Loading branch information
styczynski authored Nov 3, 2017
1 parent 5809cea commit 261aa01
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions utest.sh
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -1020,6 +1020,10 @@ function test_err {
fi
}

function safename {
echo "$1" | tr -cd '[[:alnum:]].@_-'
}

function evalspec {
code="${1/\%/\$}"
eval $code
Expand All @@ -1037,6 +1041,8 @@ function evalspecplain {
function load_prop_variable {
input_var_name="${1}${2}"
output_var_name="${3}"
output_var_name=$(safename "${output_var_name}")
input_var_name=$(safename "${input_var_name}")
input_var_value_raw="${!input_var_name}"
input_var_value="$input_var_value_raw"
if [[ "$4" != "false" ]]; then
Expand Down Expand Up @@ -1066,8 +1072,12 @@ function load_prop_value {
function load_prop_variable_arr {
input_var_name="${1}${2}[@]"
output_var_name="${3}"
input_var_name=$(safename "${input_var_name}")
output_var_name=$(safename "${output_var_name}")

#input_var_value=$(eval echo "\"\${${input_var_name}[@]}\"")
input_var_value=$(safename "${input_var_value}")
output_var_value=$(safename "${output_var_value}")
input_var_value=( ${!input_var_name} )
output_var_value=( ${!output_var_name} )

Expand Down Expand Up @@ -1236,6 +1246,7 @@ function unload_single_test_configuration_file {
function run_hook {
sbusy
hook_name="flag_hook_${1}[@]"
hook_name=$(safename "${hook_name}")
hook_value=( ${!hook_name} )

hook_result=""
Expand Down

0 comments on commit 261aa01

Please sign in to comment.