Commit 6e0dc374 authored by Ramkumar Ramachandra's avatar Ramkumar Ramachandra Committed by Arnaldo Carvalho de Melo

perf completion: Use more comp words

The completion words $words and $cword are available, so we might as
well use them instead of directly accessing COMP_WORDS.
Signed-off-by: default avatarRamkumar Ramachandra <artagnon@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Link: http://lkml.kernel.org/r/1372941691-14684-8-git-send-email-artagnon@gmail.comSigned-off-by: default avatarArnaldo Carvalho de Melo <acme@redhat.com>
parent c3fb6717
...@@ -92,15 +92,15 @@ __ltrim_colon_completions() ...@@ -92,15 +92,15 @@ __ltrim_colon_completions()
type perf &>/dev/null && type perf &>/dev/null &&
_perf() _perf()
{ {
local cur prev cmd local cur words cword prev cmd
COMPREPLY=() COMPREPLY=()
_get_comp_words_by_ref -n : cur prev _get_comp_words_by_ref -n =: cur words cword prev
cmd=${COMP_WORDS[0]} cmd=${words[0]}
# List perf subcommands or long options # List perf subcommands or long options
if [ $COMP_CWORD -eq 1 ]; then if [ $cword -eq 1 ]; then
if [[ $cur == --* ]]; then if [[ $cur == --* ]]; then
COMPREPLY=( $( compgen -W '--help --version \ COMPREPLY=( $( compgen -W '--help --version \
--exec-path --html-path --paginate --no-pager \ --exec-path --html-path --paginate --no-pager \
...@@ -110,13 +110,13 @@ _perf() ...@@ -110,13 +110,13 @@ _perf()
COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
fi fi
# List possible events for -e option # List possible events for -e option
elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
evts=$($cmd list --raw-dump) evts=$($cmd list --raw-dump)
COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) )
__ltrim_colon_completions $cur __ltrim_colon_completions $cur
# List long option names # List long option names
elif [[ $cur == --* ]]; then elif [[ $cur == --* ]]; then
subcmd=${COMP_WORDS[1]} subcmd=${words[1]}
opts=$($cmd $subcmd --list-opts) opts=$($cmd $subcmd --list-opts)
COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
fi fi
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment