diff options
author | Ramkumar Ramachandra <artagnon@gmail.com> | 2013-11-17 11:13:23 -0500 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2013-11-27 12:58:35 -0500 |
commit | 2cf025e69543f5f4aa68e8549d60680515fef5ad (patch) | |
tree | e725c9d6c1e057a0a7dfa538a52cce49c5268624 /tools/perf | |
parent | bf80669e4f689f181f23a54dfe2a0f264147ad67 (diff) |
perf completion: Introduce a layer of indirection
Define the variables cur, words, cword, and prev outside the main
completion function so that we have a chance to override it when we
introduce zsh support.
Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Link: http://lkml.kernel.org/r/1384704807-15779-2-git-send-email-artagnon@gmail.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf')
-rw-r--r-- | tools/perf/bash_completion | 17 |
1 files changed, 11 insertions, 6 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion index 62e157db2e2b..3efdc84f112c 100644 --- a/tools/perf/bash_completion +++ b/tools/perf/bash_completion | |||
@@ -89,15 +89,12 @@ __ltrim_colon_completions() | |||
89 | fi | 89 | fi |
90 | } | 90 | } |
91 | 91 | ||
92 | type perf &>/dev/null && | 92 | __perf_main () |
93 | _perf() | ||
94 | { | 93 | { |
95 | local cur words cword prev cmd | 94 | local cmd |
96 | |||
97 | COMPREPLY=() | ||
98 | _get_comp_words_by_ref -n =: cur words cword prev | ||
99 | 95 | ||
100 | cmd=${words[0]} | 96 | cmd=${words[0]} |
97 | COMPREPLY=() | ||
101 | 98 | ||
102 | # List perf subcommands or long options | 99 | # List perf subcommands or long options |
103 | if [ $cword -eq 1 ]; then | 100 | if [ $cword -eq 1 ]; then |
@@ -120,6 +117,14 @@ _perf() | |||
120 | opts=$($cmd $subcmd --list-opts) | 117 | opts=$($cmd $subcmd --list-opts) |
121 | COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) | 118 | COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) |
122 | fi | 119 | fi |
120 | } | ||
121 | |||
122 | type perf &>/dev/null && | ||
123 | _perf() | ||
124 | { | ||
125 | local cur words cword prev | ||
126 | _get_comp_words_by_ref -n =: cur words cword prev | ||
127 | __perf_main | ||
123 | } && | 128 | } && |
124 | 129 | ||
125 | complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \ | 130 | complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \ |