I have this script:
#!/bin/bash
a=`git rev-parse --abbrev-ref HEAD`
echo $a
if [[ "$a" =~ release* ]]; then
echo "not valid branch allowed to be created"
exit 1
fi
What I am trying to achieve is that only if the value of a starts with the string release, then the script should exit with status 1.
I want to make sure I validate the value of a against a regex that always starts with the string release and can have any other characters or numbers or special characters after that. However, I see in the script that if a includes the string release anywhere in its value, the script still matches it with the regex and prints the value under the echo.
How do I get the regex right here?