Test if a value is in a list.
in-list
tests if given string is found in a list.
Test if given string is found in the remaining arguments.
source "${BASH_SOURCE[0]%/*}/libs/biapy-bashlings/src/in-list.bash"
value='te(x|s)t'
example_list=( 'test' 'second text' 10 11 )
if in-list "${value}" ${example_list[@]+"${example_list[@]}"} then
echo "Found."
else
echo "Error: Not found." >&2
exit 1
fi
- $1 (string): The searched string, allow for regex syntax (excluding ^ and $).
- ... (any): The contents of the list in which the string is searched.
- 0: If string is found in list.
- 1: If string is not found in list, or string is missing.
- Display an error if string is missing.