`bb_array_contains_value` line 2144: _index: unbound variable
When using bb_array_contains_value
with bash 5 it does not return 0 or 1, but the error line 2144: _index: unbound variable
Full bash version, example code and error message below.
garfield@aglio:~$ bash --version
GNU bash, version 5.0.17(1)-release (x86_64-pc-linux-gnu)
Copyright (C) 2019 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software; you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
garfield@aglio:~$ cat ~/tmp/test.bash
#!/usr/bin/env bash
source /usr/local/libexec/bash-base.bash
declare -a test=([0]="nop0" [1]="nop1")
declare -p test
bb_array_contains_value test "nop" || echo "not found"
bb_quit
garfield@aglio:~$ ~/tmp/test.bash
declare -a test=([0]="nop0" [1]="nop1")
/usr/local/libexec/bash-base.bash: line 2144: _index: unbound variable
test.bash: _bb_err_exit_trap: unexpected exit/error near '_index=$(( _index + 1 ))', status=1, trap=EXIT
test.bash: Execution at file "/usr/local/libexec/bash-base.bash", line 3505, function "_bb_err_exit_trap"
test.bash: Called from file "/usr/local/libexec/bash-base.bash", line 1, function "_bb_array_filter_x"
test.bash: Called from file "/usr/local/libexec/bash-base.bash", line 2166, function "bb_array_filter"
test.bash: Called from file "/usr/local/libexec/bash-base.bash", line 1097, function "bb_array_contains_value"
test.bash: Called from file "/home/garfield/tmp/test.bash", line 7