It's difficult to make values like 'release[remote]' to become properly quoted or escaped because if the current word starts with a quote (which can be a ', a ", or a $'), a manually quoted COMPREPLY value like release\[remote\] will make the completed value include the backslashes (e.g. 'release\[remote\]'). On the other hand if a COMPREPLY value isn't escaped with backslashes, the result will be a plain release[remote] (no backslash escapes) which results to unintended globbing. A possible workaround for this would be to check if the current word is openly quoted before deciding if manually quoting is needed or not. And the only clean-and-close-to-accurate way of doing it is to process the word against compgen -W and do tests. Manual parsing would be terrible.
If `complete` can have an option which forces all completed values to be properly quoted, this manual quoting hacks wouldn't be needed. -- konsolebox