Commit fa6fb3ca authored by Emeric Verschuur's avatar Emeric Verschuur
Browse files

Fix fix bash eval + test add

parent 2c68ee36
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -249,7 +249,7 @@ bashopts_declare() {
        bashopts_opt2name[--${options[long_opt]}]=${options[name]}
    fi
    for f in ${!options[@]}; do
        eval bashopts_optprop_$f[${options[name]}]=\'${options[$f]//\'/\'\\\'\'}\'
        eval "bashopts_optprop_$f[${options[name]}]='${options[$f]//\'/\'\\\'\'}'"
    done
    bashopts_optlist+=(${options[name]})
}
+34 −21
Original line number Diff line number Diff line
@@ -19,7 +19,7 @@
# under the License.

if [ "$GITLAB_CI" != "true" ]; then
    exec docker run --rm -ti -e GITLAB_CI=true -v $PWD:$PWD -w $PWD ubuntu:16.04 ./test.sh
    exec docker run --rm -ti -e GITLAB_CI=true -v $PWD:$PWD -w $PWD ubuntu:16.04 ./test.sh "$@"
fi

. bashopts.sh
@@ -93,9 +93,9 @@ _test_case_4() {
}

_test_case_5() {
    rm -f /tmp/myapp_case4rc
    rm -f /tmp/myapp_case5rc

    bashopts_setup -n "myapp_case4" -d "Test case 4" -s /tmp/myapp_case4rc
    bashopts_setup -n "myapp_case5" -d "Test case 5" -s /tmp/myapp_case5rc

    bashopts_declare -n array_value -l value -m add -d "Array value" -t string -s

@@ -105,6 +105,19 @@ _test_case_5() {
    req_test_eq "${#array_value[@]}" "0"
}

_test_case_6() {
    rm -f /tmp/myapp_case6rc

    bashopts_setup -n "myapp_case6" -d "Test case 6"

    bashopts_declare -n computed_value -e '$(( 2 + 3 * 4 ))' -t string

    bashopts_parse_args
    bashopts_process_args

    req_test_eq "$computed_value" "14"
}

if [ ${#} -eq 0 ]; then
    for t in $(grep -E -o '_test_case_\w+\>' $0); do
        echo "=> Test case $t"