Here is my script:
#!/bin/bash
x="aabcaa"
y=${x##*(a)}
echo $y
It outputs aabcaa when I expect bcaa.
When I try the same commands on a bash shell (got with bash command from zsh shell), everything works as I want. I checked the version with bash --version and /bin/bash --version. Obviously, the two commands output the same thing. The unexpected behavior of the script is the same in a zsh shell and in a bash shell.
What could be wrong?