[[ "$x" =~ '^[0-9]$' ]]. This command succeeded in Debian when
$xis a single digit, but failed in Gentoo. I had to remove the single quotes surround the regular expression to make it work in Gentoo.
Today I finally found the reason: I was using bash 3.1 in Debian and 3.2 in Gentoo. Bash 3.2 by default mandates that regular expressions not be surrounded by quotes; however, the behavior can be modified using
shopt -s compat31.