completions/cs.bash in cloudstack-cli-0.8.1 vs completions/cs.bash in cloudstack-cli-0.8.2
- old
+ new
@@ -24,18 +24,18 @@
local words=("${COMP_WORDS[@]}")
# ignore commands which contain 'help'
if [[ "${words[@]}" == *help* ]]; then
COMPREPLY=( $(compgen -W '' -- "$word") )
# search for subcommand
- elif [[ "$word" != -* ]] && [ -n "$word" ]; then
+ elif [[ "$word" != -* ]] && [ "$COMP_CWORD" -eq 2 ]; then
local cp1=$(echo ${words[@]} | cut -d ' ' -f1-2)
COMPREPLY=( $(compgen -W "$($cp1 help | grep cs | cut -d ' ' -f5)" -- "$word") )
# list options for the subcommand
- elif [[ "$word" =~ -* ]] && [ $(echo ${words[@]} | wc -w) -gt 2 ]; then
+ elif [[ "$word" =~ -* ]] && [ "$COMP_CWORD" -gt 2 ]; then
local cp1=$(echo ${words[@]} | cut -d ' ' -f1-2)
local cp2=$(echo ${words[@]} | cut -d ' ' -f3)
local cp3=$($cp1 help $cp2 2>/dev/null)
- COMPREPLY=( $(compgen -W "$(echo $cp3 | awk 'NR>1{print $1}' RS=[ FS='\=')" -- "$word") )
+ COMPREPLY=( $(compgen -W "$(echo $cp3 | awk 'NR>1{print $1}' RS=[ FS='\=') 2>/dev/null" -- "$word") )
fi
fi
}
complete -F _cs cs
\ No newline at end of file