bash completion for git branch/checkout/etc doesn't escape metacharacters
- From
- Kevin Stenerson <kevin@reflexionhealth.com>
- Date
- Jan 20, 2015, 19:15 UTC
- Message-ID
- <CAPcx8dzgnChWpTn6po1NF65Mr_hPadUbbNCKHJqght7OG6ksFw@mail.gmail.com>
The bash completion provided with git doesn't escape or quote parens in tag or branch names. Alternatively, it doesn't reject branch or tag names with parenthesis as an invalid name (as it does for names with spaces or tabs) Bash treats parentheses in unquoted words as a word separator.
When encountering this problem I was using git version 2.2.2 and bash version 4.3.11
Steps to reproduce with bash:
mkdir foo
cd foo
git init foo
touch bar
git add bar
git commit -m "Went to a bar"Then for tags
git tag 'v1.0.0(215)'
Or branches
git branch 'mybranch(myuser)'
And the actual bash completion
git checkout # Use completion here -- it won't escape the parenthesis
git checkout master
git branch -d # Use completion here -- it won't escape the parenthesisSimilarily, when typing a name with an escape character such as "mytag\(", it won't complete the name from that point.
This appears to be true for other bash meta characters as well such as '<', '>', '|', ';', '&'
----------- Kevin Stenerson kevin@reflexionhealth.com