In a PE pattern, if the pattern has a single quoted part that contains $( and does not contain a closing parenthesis, and has \' at the end, bash will try to parse a command substitution and fail.
$ echo "${HOME#'$('\'}" bash: command substitution: line 3: unexpected EOF while looking for matching `"' $ echo "${HOME#aaaa'$(aaaa'aaa)aaa\'}" bash: command substitution: line 5: unexpected EOF while looking for matching `"' $ echo "${HOME#aaaa'$(aaaa)'aaaa\'}" /home/emanuele6 I was able to reprodcue this bug in all versions starting from bash 4.3. o/ emanuele6