Loading bashopts.sh +1 −1 Original line number Diff line number Diff line Loading @@ -522,7 +522,7 @@ bashopts_process_args() { if [ -f "$bashopts_tool_settings_path" ]; then sed -i "/^$op=/d" $bashopts_tool_settings_path fi if [ "${!op}" != "$dval" ]; then if [ "$(bashopts_get_def $op)" != "$(bashopts_get_def dval)" ]; then echo "$(bashopts_get_def_full $op)" >> $bashopts_tool_settings_path fi ) || bashopts_warning "Please check the settings file" Loading test.sh +37 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,43 @@ _test_case_14() { req_test_eq "${array_value[1]}" "false" } _test_case_15() { rm -f /tmp/bashopts_testrc bashopts_setup -n "$0" -d "Test case $0" -s /tmp/bashopts_testrc bashopts_declare -n array_value -l value -m add -d "Array value" -s -i -t string -e '("value 1" "value 2")' bashopts_parse_args --value "" bashopts_process_args > /dev/null <<< '( "value 1" "value 3" )' req_test_eq "${#array_value[@]}" "2" req_test_eq "${array_value[0]}" "value 1" req_test_eq "${array_value[1]}" "value 3" if [ ! -f /tmp/bashopts_testrc ]; then echo "file /tmp/bashopts_testrc should be present" exit 1 fi req_test_eq "$(cat /tmp/bashopts_testrc)" 'array_value=([0]="value 1" [1]="value 3")' } _test_case_16() { rm -f /tmp/bashopts_testrc bashopts_setup -n "$0" -d "Test case $0" -s /tmp/bashopts_testrc bashopts_declare -n array_value -l value -m add -d "Array value" -s -i -t string -e '("value 1" "value 2")' bashopts_parse_args --value "" bashopts_process_args > /dev/null <<< '( "value 1" "value 2" )' req_test_eq "${#array_value[@]}" "2" req_test_eq "${array_value[0]}" "value 1" req_test_eq "${array_value[1]}" "value 2" if [ -f /tmp/bashopts_testrc ]; then echo "file /tmp/bashopts_testrc should not be present" exit 1 fi } if [ ${#} -eq 0 ]; then for t in $(grep -E -o '_test_case_\w+\>' $0); do echo "=> Test case $t" Loading Loading
bashopts.sh +1 −1 Original line number Diff line number Diff line Loading @@ -522,7 +522,7 @@ bashopts_process_args() { if [ -f "$bashopts_tool_settings_path" ]; then sed -i "/^$op=/d" $bashopts_tool_settings_path fi if [ "${!op}" != "$dval" ]; then if [ "$(bashopts_get_def $op)" != "$(bashopts_get_def dval)" ]; then echo "$(bashopts_get_def_full $op)" >> $bashopts_tool_settings_path fi ) || bashopts_warning "Please check the settings file" Loading
test.sh +37 −0 Original line number Diff line number Diff line Loading @@ -210,6 +210,43 @@ _test_case_14() { req_test_eq "${array_value[1]}" "false" } _test_case_15() { rm -f /tmp/bashopts_testrc bashopts_setup -n "$0" -d "Test case $0" -s /tmp/bashopts_testrc bashopts_declare -n array_value -l value -m add -d "Array value" -s -i -t string -e '("value 1" "value 2")' bashopts_parse_args --value "" bashopts_process_args > /dev/null <<< '( "value 1" "value 3" )' req_test_eq "${#array_value[@]}" "2" req_test_eq "${array_value[0]}" "value 1" req_test_eq "${array_value[1]}" "value 3" if [ ! -f /tmp/bashopts_testrc ]; then echo "file /tmp/bashopts_testrc should be present" exit 1 fi req_test_eq "$(cat /tmp/bashopts_testrc)" 'array_value=([0]="value 1" [1]="value 3")' } _test_case_16() { rm -f /tmp/bashopts_testrc bashopts_setup -n "$0" -d "Test case $0" -s /tmp/bashopts_testrc bashopts_declare -n array_value -l value -m add -d "Array value" -s -i -t string -e '("value 1" "value 2")' bashopts_parse_args --value "" bashopts_process_args > /dev/null <<< '( "value 1" "value 2" )' req_test_eq "${#array_value[@]}" "2" req_test_eq "${array_value[0]}" "value 1" req_test_eq "${array_value[1]}" "value 2" if [ -f /tmp/bashopts_testrc ]; then echo "file /tmp/bashopts_testrc should not be present" exit 1 fi } if [ ${#} -eq 0 ]; then for t in $(grep -E -o '_test_case_\w+\>' $0); do echo "=> Test case $t" Loading