threads / discuss / 38412

bash completion for git branch/checkout/etc doesn't escape metacharacters

Subject: bash completion for git branch/checkout/etc doesn't escape metacharacters

## tl;dr

One message between Jan 20, 2015 and Jan 20, 2015.

replies: 0people: 1as markdown or json

Kevin Stenerson· Jan 20, 2015, 19:15 UTC · lore

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 parenthesis

Similarily, 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

← back to recent threads