diff options
author | Ramkumar Ramachandra <artagnon@gmail.com> | 2013-11-17 11:13:25 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-27 12:58:35 -0500 |
commit | 37e72c31061521d6f0e4b7fe47cd5748280ed691 (patch) | |
tree | c4f3e5bf051aea2081b1082302ed29247c427de6 | |
parent | 12f9dd5042483698c74a133d9004ff1d1a6474f9 (diff) |
perf completion: Factor out call to __ltrim_colon_completions
In our sole callsite, __ltrim_colon_completions is called after
__perfcomp, to modify the COMPREPLY set by the invocation.
This is problematic, because in the zsh equivalent (using compset/
compadd), we'll have to generate completions in one-shot.
So factor out this entire callsite into a special override'able
__perfcomp_colon function; we will override it when introducing zsh
support.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1384704807-15779-4-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
-rw-r--r-- | tools/perf/bash_completion | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion index 824312681601..573599b42be2 100644 --- a/tools/perf/bash_completion +++ b/tools/perf/bash_completion | |||
@@ -94,6 +94,12 @@ __perfcomp () | |||
94 | COMPREPLY=( $( compgen -W "$1" -- "$2" ) ) | 94 | COMPREPLY=( $( compgen -W "$1" -- "$2" ) ) |
95 | } | 95 | } |
96 | 96 | ||
97 | __perfcomp_colon () | ||
98 | { | ||
99 | __perfcomp "$1" "$2" | ||
100 | __ltrim_colon_completions $cur | ||
101 | } | ||
102 | |||
97 | __perf_main () | 103 | __perf_main () |
98 | { | 104 | { |
99 | local cmd | 105 | local cmd |
@@ -114,8 +120,7 @@ __perf_main () | |||
114 | # List possible events for -e option | 120 | # List possible events for -e option |
115 | elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then | 121 | elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then |
116 | evts=$($cmd list --raw-dump) | 122 | evts=$($cmd list --raw-dump) |
117 | __perfcomp "$evts" "$cur" | 123 | __perfcomp_colon "$evts" "$cur" |
118 | __ltrim_colon_completions $cur | ||
119 | # List long option names | 124 | # List long option names |
120 | elif [[ $cur == --* ]]; then | 125 | elif [[ $cur == --* ]]; then |
121 | subcmd=${words[1]} | 126 | subcmd=${words[1]} |