I want to create a bash function that iterates over an array and returns 0 if an element passed as argument does not exist in the array, or 1 otherwise.
The following code however does not print anything on stdout.
function checkparsed {
tocheck="$1"
shift
for item in $@
do
if [ "$item" = "$tocheck" ]; then
return 0
fi
done
return 1
}
mdfiles=('foo')
echo "$(checkparsed foo ${mdfiles[@]})"