I have a variable called PARAM_COMPARE which is set to *.md.
I'd like to compare filenames from GitHub Commits endpoint against PARAM_COMPARE.
gh api repos/"$PARAM_GH_PROJECT"/"$PARAM_GH_REPO"/commits/"$PARAM_GH_SHA" | jq -r '.files[].filename' | while read filename; do
echo "${filename}" "${PARAM_COMPARE}"
if [[ $filename =~ $PARAM_COMPARE ]]; then
echo matched
break
fi
done
This sadly says it is not a match, even when the filename is README.md.
Have I forgotten something in this script?
*.mdis not a regex, it is a glob pattern. Use[[ $filename = $PARAM_COMPARE ]]case $filename in $PARAM_COMPARE ) ... ;; esac