I've been writing my own Linux $SHELL and one of the features is that asterisks don't get expanded by the shell to avoid accidental bugs from the situations you described.
rm $(glob *.bak)
rm @{g *.bak}
This way you don't need to worry about spaces in file names or other problems with escaping.
I've been writing my own Linux $SHELL and one of the features is that asterisks don't get expanded by the shell to avoid accidental bugs from the situations you described.