I want this to only output "match!" if only the single character "a" or "b" is passed as an argument. Not aaaaa, not bcfqwefqef, not qwerty.
#!/bin/bash
P="a|b"
if [[ "$1" =~ $P ]]; then
echo "match!"
else
echo "no!"
fi
Yes i've gone through some SO posts to get this far already. Putting $P in quotes doesn't work either.