From 02fde323b9aaebb4a21e7c0e04759470b6c07594 Mon Sep 17 00:00:00 2001 From: Yunlong Song Date: Wed, 18 Mar 2015 21:35:46 +0800 Subject: [PATCH] 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 --', where 'kvm|kmem|mem|lock|sched' are all subcommands of perf. Example: Before this patch: $ perf kvm -- $ As shown above, the options of perf kvm does not come out. After this patch: $ perf kvm -- --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 Tested-by: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1426685758-25488-2-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/perf-completion.sh | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index c2595e9bd69b..4822ed38e23e 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -119,15 +119,18 @@ __perf_main () elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) __perfcomp_colon "$evts" "$cur" - # List subcommands for perf commands - elif [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then - subcmds=$($cmd $prev --list-cmds) - __perfcomp_colon "$subcmds" "$cur" - # List long option names - elif [[ $cur == --* ]]; then - subcmd=${words[1]} - opts=$($cmd $subcmd --list-opts) - __perfcomp "$opts" "$cur" + else + # List subcommands for perf commands + if [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then + subcmds=$($cmd $prev --list-cmds) + __perfcomp_colon "$subcmds" "$cur" + fi + # List long option names + if [[ $cur == --* ]]; then + subcmd=${words[1]} + opts=$($cmd $subcmd --list-opts) + __perfcomp "$opts" "$cur" + fi fi } -- 2.39.5