From 28d64afc726d38a411efeda6b61a4f9ff77547d8 Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones Date: Fri, 25 Apr 2014 13:50:09 -0400 Subject: Fix bash-completion support for -C option to expand tilde --- misc/bash-completion | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/misc/bash-completion b/misc/bash-completion index 719e7a8..ecb6c54 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -28,7 +28,8 @@ _ninja_target() { # 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" ;; + # eval for tilde expansion + C) eval dir="$OPTARG" ;; esac done; targets_command="eval ninja -C \"${dir}\" -t targets all" -- cgit v0.12 From 43645ff15bdd376c6484305ef35191a5bf43e446 Mon Sep 17 00:00:00 2001 From: Taylor Braun-Jones Date: Fri, 25 Apr 2014 13:59:53 -0400 Subject: Style: Fix inconsistent indentation --- misc/bash-completion | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/misc/bash-completion b/misc/bash-completion index ecb6c54..0ca5235 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -19,23 +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 - # 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 + 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 -- cgit v0.12