aboutsummaryrefslogtreecommitdiffstats
path: root/tools/perf/bash_completion
diff options
context:
space:
mode:
authorRamkumar Ramachandra <artagnon@gmail.com>2013-11-17 11:13:24 -0500
committerArnaldo Carvalho de Melo <acme@redhat.com>2013-11-27 12:58:35 -0500
commit12f9dd5042483698c74a133d9004ff1d1a6474f9 (patch)
tree780bc2bee413dffa36943d3b9c97e3a28670c6fe /tools/perf/bash_completion
parent2cf025e69543f5f4aa68e8549d60680515fef5ad (diff)
perf completion: Factor out compgen stuff
compgen is a bash-builtin; factor out the invocations into a separate function to give us a chance to override it with a zsh equivalent in future patches. Signed-off-by: Ramkumar Ramachandra <artagnon@gmail.com> Cc: Ingo Molnar <mingo@kernel.org> Link: http://lkml.kernel.org/r/1384704807-15779-3-git-send-email-artagnon@gmail.com Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools/perf/bash_completion')
-rw-r--r--tools/perf/bash_completion15
1 files changed, 10 insertions, 5 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 3efdc84f112c..824312681601 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -89,6 +89,11 @@ __ltrim_colon_completions()
89 fi 89 fi
90} 90}
91 91
92__perfcomp ()
93{
94 COMPREPLY=( $( compgen -W "$1" -- "$2" ) )
95}
96
92__perf_main () 97__perf_main ()
93{ 98{
94 local cmd 99 local cmd
@@ -99,23 +104,23 @@ __perf_main ()
99 # List perf subcommands or long options 104 # List perf subcommands or long options
100 if [ $cword -eq 1 ]; then 105 if [ $cword -eq 1 ]; then
101 if [[ $cur == --* ]]; then 106 if [[ $cur == --* ]]; then
102 COMPREPLY=( $( compgen -W '--help --version \ 107 __perfcomp '--help --version \
103 --exec-path --html-path --paginate --no-pager \ 108 --exec-path --html-path --paginate --no-pager \
104 --perf-dir --work-tree --debugfs-dir' -- "$cur" ) ) 109 --perf-dir --work-tree --debugfs-dir' -- "$cur"
105 else 110 else
106 cmds=$($cmd --list-cmds) 111 cmds=$($cmd --list-cmds)
107 COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) ) 112 __perfcomp "$cmds" "$cur"
108 fi 113 fi
109 # List possible events for -e option 114 # List possible events for -e option
110 elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then 115 elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then
111 evts=$($cmd list --raw-dump) 116 evts=$($cmd list --raw-dump)
112 COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) 117 __perfcomp "$evts" "$cur"
113 __ltrim_colon_completions $cur 118 __ltrim_colon_completions $cur
114 # List long option names 119 # List long option names
115 elif [[ $cur == --* ]]; then 120 elif [[ $cur == --* ]]; then
116 subcmd=${words[1]} 121 subcmd=${words[1]}
117 opts=$($cmd $subcmd --list-opts) 122 opts=$($cmd $subcmd --list-opts)
118 COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) ) 123 __perfcomp "$opts" "$cur"
119 fi 124 fi
120} 125}
121 126