https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
When braces are used, the matching ending brace is the first ‘}’ not escaped by a backslash or within a quoted string, and not within an embedded arithmetic expansion, command substitution, or parameter expansion.
following code (from __parse_options() inside msys2's usr\share\bash-completion\bash_completion script) is messed by incorrect nesting:
# Expand --[no]foo to --foo and --nofoo etc
if [[ $option =~ (\[((no|dont)-?)\]). ]]; then
option2=${option/"${BASH_REMATCH[1]}"/}
option2=${option2%%[<{().[]*}
printf '%s\n' "${option2/=*/=}"
option=${option/"${BASH_REMATCH[1]}"/"${BASH_REMATCH[2]}"}
fi
option=${option%%[<{().[]*}
printf '%s\n' "${option/=*/=}"
https://www.gnu.org/software/bash/manual/bash.html#Shell-Parameter-Expansion
following code (from
__parse_options()inside msys2'susr\share\bash-completion\bash_completionscript) is messed by incorrect nesting: