浏览代码

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>
Ramkumar Ramachandra 12 年之前
父节点
当前提交
2cf025e695
共有 1 个文件被更改,包括 11 次插入6 次删除
  1. 11 6
      tools/perf/bash_completion

+ 11 - 6
tools/perf/bash_completion

@@ -89,15 +89,12 @@ __ltrim_colon_completions()
 	fi
 	fi
 }
 }
 
 
-type perf &>/dev/null &&
-_perf()
+__perf_main ()
 {
 {
-	local cur words cword prev cmd
-
-	COMPREPLY=()
-	_get_comp_words_by_ref -n =: cur words cword prev
+	local cmd
 
 
 	cmd=${words[0]}
 	cmd=${words[0]}
+	COMPREPLY=()
 
 
 	# List perf subcommands or long options
 	# List perf subcommands or long options
 	if [ $cword -eq 1 ]; then
 	if [ $cword -eq 1 ]; then
@@ -120,6 +117,14 @@ _perf()
 		opts=$($cmd $subcmd --list-opts)
 		opts=$($cmd $subcmd --list-opts)
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
 		COMPREPLY=( $( compgen -W '$opts' -- "$cur" ) )
 	fi
 	fi
+}
+
+type perf &>/dev/null &&
+_perf()
+{
+	local cur words cword prev
+	_get_comp_words_by_ref -n =: cur words cword prev
+	__perf_main
 } &&
 } &&
 
 
 complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \
 complete -o bashdefault -o default -o nospace -F _perf perf 2>/dev/null \