diff options
author | Nico Weber <nicolasweber@gmx.de> | 2014-04-25 21:06:03 (GMT) |
---|---|---|
committer | Nico Weber <nicolasweber@gmx.de> | 2014-04-25 21:06:03 (GMT) |
commit | fdabe7c74d426b0496a22198416898b3b701bb8d (patch) | |
tree | c7155b87799f150325e7b77456eb548c717e588f /misc | |
parent | 8fe13f5dabfc5e1581d2fc82fd7f535bdd70ce0c (diff) | |
parent | 43645ff15bdd376c6484305ef35191a5bf43e446 (diff) | |
download | Ninja-fdabe7c74d426b0496a22198416898b3b701bb8d.zip Ninja-fdabe7c74d426b0496a22198416898b3b701bb8d.tar.gz Ninja-fdabe7c74d426b0496a22198416898b3b701bb8d.tar.bz2 |
Merge pull request #747 from nocnokneo/master
Fix bash-completion support for -C option to expand tilde
Diffstat (limited to 'misc')
-rw-r--r-- | misc/bash-completion | 33 |
1 files changed, 17 insertions, 16 deletions
diff --git a/misc/bash-completion b/misc/bash-completion index 719e7a8..0ca5235 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -19,22 +19,23 @@ _ninja_target() { local cur targets dir line targets_command OPTIND cur="${COMP_WORDS[COMP_CWORD]}" - if [[ "$cur" == "--"* ]]; then - # there is currently only one argument that takes -- - COMPREPLY=($(compgen -P '--' -W 'version' -- "${cur:2}")) - else - dir="." - line=$(echo ${COMP_LINE} | cut -d" " -f 2-) - # filter out all non relevant arguments but keep C for dirs - while getopts C:f:j:l:k:nvd:t: opt $line; do - case $opt in - C) dir="$OPTARG" ;; - esac - done; - targets_command="eval ninja -C \"${dir}\" -t targets all" - targets=$((${targets_command} 2>/dev/null) | awk -F: '{print $1}') - COMPREPLY=($(compgen -W "$targets" -- "$cur")) - fi + if [[ "$cur" == "--"* ]]; then + # there is currently only one argument that takes -- + COMPREPLY=($(compgen -P '--' -W 'version' -- "${cur:2}")) + else + dir="." + line=$(echo ${COMP_LINE} | cut -d" " -f 2-) + # filter out all non relevant arguments but keep C for dirs + while getopts C:f:j:l:k:nvd:t: opt $line; do + case $opt in + # eval for tilde expansion + C) eval dir="$OPTARG" ;; + esac + done; + targets_command="eval ninja -C \"${dir}\" -t targets all" + targets=$((${targets_command} 2>/dev/null) | awk -F: '{print $1}') + COMPREPLY=($(compgen -W "$targets" -- "$cur")) + fi return } complete -F _ninja_target ninja |