From 1f38478eb976d3c11db7885972664c0422317ea8 Mon Sep 17 00:00:00 2001 From: Allan Odgaard Date: Tue, 15 Apr 2014 14:23:47 +0700 Subject: Fix bash completion when using command options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By quoting the ‘line’ variable we are making it a single word, but ‘getopts’ wants each option as its own word. Previously bash completion would output an error for a line like: ‘ninja -vn targ‸’. In addition to removing the quotes (to enable word expansion) I also used it as a regular variable, as that is what it is (not an array). --- misc/bash-completion | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/misc/bash-completion b/misc/bash-completion index 2d6975b..93bc9a1 100644 --- a/misc/bash-completion +++ b/misc/bash-completion @@ -26,7 +26,7 @@ _ninja_target() { 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 + while getopts C:f:j:l:k:nvd:t: opt $line; do case $opt in C) dir="$OPTARG" ;; esac -- cgit v0.12