diff --git a/bash-ini-parser b/bash-ini-parser index 4798d62..27aa743 100644 --- a/bash-ini-parser +++ b/bash-ini-parser @@ -53,11 +53,12 @@ function cfg_parser { ini[${#ini[*]} + 1]='}' # add the last brace debug eval "$(echo "${ini[*]}")" # eval the result + EVAL_STATUS=$? if [ $CHANGE_EXTGLOB = 1 ] then shopt -u extglob fi - + return $EVAL_STATUS } function cfg_writer { diff --git a/t/t0002-invalid.sh b/t/t0002-invalid.sh new file mode 100755 index 0000000..3784c21 --- /dev/null +++ b/t/t0002-invalid.sh @@ -0,0 +1,17 @@ +#!/bin/sh + +SHARNESS_TEST_EXTENSION="sh" + +test_description="check invalid ini files" + +. sharness/sharness.sh + +. ../../bash-ini-parser + +DIR_TEST=$SHARNESS_TEST_DIRECTORY/t0002 + +test_expect_success "Invalid line" " + test_expect_code 1 cfg_parser $DIR_TEST/invalid.ini +" + +test_done diff --git a/t/t0002/invalid.ini b/t/t0002/invalid.ini new file mode 100644 index 0000000..bd4e24d --- /dev/null +++ b/t/t0002/invalid.ini @@ -0,0 +1,8 @@ + + +var1=VAR1 + +; Invalid line - should throw an error and stop processing +INVALID LINE +var2=VAR2 +