perf tools: Fix the bash completion for listing options of perf subcommand

The bash completion does not support listing options for 'perf
kvm|kmem|mem|lock|sched --<TAB>', where 'kvm|kmem|mem|lock|sched' are
all subcommands of perf.

Example:

Before this patch:

 $ perf kvm --<TAB>
 $

As shown above, the options of perf kvm does not come out.

After this patch:

 $ perf kvm --<TAB>
 --alloc    --caller   --input    --line     --raw-ip   --sort
 --verbose

As shown above, the options of perf kvm can come out now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426685758-25488-2-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
This commit is contained in:
Yunlong Song 2015-03-18 21:35:46 +08:00 committed by Arnaldo Carvalho de Melo
parent 76aea7731e
commit 02fde323b9

View File

@ -119,15 +119,18 @@ __perf_main ()
elif [[ $prev == "-e" && "${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)
__perfcomp_colon "$evts" "$cur" __perfcomp_colon "$evts" "$cur"
# List subcommands for perf commands else
elif [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then # List subcommands for perf commands
subcmds=$($cmd $prev --list-cmds) if [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then
__perfcomp_colon "$subcmds" "$cur" subcmds=$($cmd $prev --list-cmds)
# List long option names __perfcomp_colon "$subcmds" "$cur"
elif [[ $cur == --* ]]; then fi
subcmd=${words[1]} # List long option names
opts=$($cmd $subcmd --list-opts) if [[ $cur == --* ]]; then
__perfcomp "$opts" "$cur" subcmd=${words[1]}
opts=$($cmd $subcmd --list-opts)
__perfcomp "$opts" "$cur"
fi
fi fi
} }