diff options
author | Yunlong Song <yunlong.song@huawei.com> | 2015-03-18 09:35:48 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2015-03-19 12:49:28 -0400 |
commit | eee200a6c4a9712146ba999f944ba4f2c3fc2d44 (patch) | |
tree | 081d433830574de9d2b3a1b43a9983f7ec16a94e /tools | |
parent | 67afff485b2ce742374edb2e17d21e2bc664eb1f (diff) |
perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand
The bash completion gives wrong options for 'perf kvm|kmem|mem|lock|
sched subsubcommand --<TAB>', where 'kvm|kmem|mem|lock|sched' are all
subcommands of perf and 'subsubcommand' is a subcommand of 'kvm|kmem|mem
|lock|sched'. In fact, the result incorrectly lists the bash completion
of 'perf subcommand' rather than 'perf subcommand subsubcommand'.
Example:
Before this patch:
$ perf kvm record --<TAB>
--guest --guestkallsyms --guestmodules --guestmount
--guestvmlinux --host --input --output
--verbose
As shown above, the result is the options of kvm rather than record.
After this patch:
$ perf kvm record --<TAB>
--all-cpus --cgroup --delay --group
--no-buildid --output --quiet --stat
--uid
--branch-any --count --event --intr-regs
--no-buildid-cache --period --raw-samples --tid
--verbose
--branch-filter --cpu --filter --mmap-pages
--no-inherit --per-thread --realtime --timestamp
--weight
--call-graph --data --freq
--no-buffering --no-samples --pid
--running-time --transaction
As shown above, the result is exactly the options of record as we wished.
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-4-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/perf-completion.sh | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index bbb61d0b79cd..01ce841f155b 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh | |||
@@ -105,9 +105,12 @@ __perf_prev_skip_opts () | |||
105 | local i cmd_ cmds_ | 105 | local i cmd_ cmds_ |
106 | 106 | ||
107 | let i=cword-1 | 107 | let i=cword-1 |
108 | cmds_=$($cmd --list-cmds) | 108 | cmds_=$($cmd $1 --list-cmds) |
109 | prev_skip_opts=() | 109 | prev_skip_opts=() |
110 | while [ $i -ge 0 ]; do | 110 | while [ $i -ge 0 ]; do |
111 | if [[ ${words[i]} == $1 ]]; then | ||
112 | return | ||
113 | fi | ||
111 | for cmd_ in $cmds_; do | 114 | for cmd_ in $cmds_; do |
112 | if [[ ${words[i]} == $cmd_ ]]; then | 115 | if [[ ${words[i]} == $cmd_ ]]; then |
113 | prev_skip_opts=${words[i]} | 116 | prev_skip_opts=${words[i]} |
@@ -146,7 +149,9 @@ __perf_main () | |||
146 | fi | 149 | fi |
147 | # List long option names | 150 | # List long option names |
148 | if [[ $cur == --* ]]; then | 151 | if [[ $cur == --* ]]; then |
149 | subcmd=${words[1]} | 152 | subcmd=$prev_skip_opts |
153 | __perf_prev_skip_opts $subcmd | ||
154 | subcmd=$subcmd" "$prev_skip_opts | ||
150 | opts=$($cmd $subcmd --list-opts) | 155 | opts=$($cmd $subcmd --list-opts) |
151 | __perfcomp "$opts" "$cur" | 156 | __perfcomp "$opts" "$cur" |
152 | fi | 157 | fi |