lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date:	Sun, 22 Mar 2015 03:09:29 -0700
From:	tip-bot for Yunlong Song <tipbot@...or.com>
To:	linux-tip-commits@...r.kernel.org
Cc:	acme@...hat.com, wangnan0@...wei.com, linux-kernel@...r.kernel.org,
	paulus@...ba.org, yunlong.song@...wei.com, tglx@...utronix.de,
	mingo@...nel.org, a.p.zijlstra@...llo.nl, hpa@...or.com
Subject: [tip:perf/core] perf tools:
  Fix the bash completion for listing subsubcommands of perf subcommand

Commit-ID:  67afff485b2ce742374edb2e17d21e2bc664eb1f
Gitweb:     http://git.kernel.org/tip/67afff485b2ce742374edb2e17d21e2bc664eb1f
Author:     Yunlong Song <yunlong.song@...wei.com>
AuthorDate: Wed, 18 Mar 2015 21:35:47 +0800
Committer:  Arnaldo Carvalho de Melo <acme@...hat.com>
CommitDate: Thu, 19 Mar 2015 13:49:20 -0300

perf tools: Fix the bash completion for listing subsubcommands of perf subcommand

The bash completion does not support listing subsubcommands for 'perf
kvm|kmem|mem|lock|sched --<long option> <TAB>', where 'kvm|kmem|mem|
lock|sched' are all subcommands of perf.

Example:

Before this patch:

 $ perf kvm --verbose <TAB>
 $

As shown above, the subsubcommands of perf kvm does not come out.

After this patch:

 $ perf kvm --verbose <TAB>
 buildid-list  diff          record        report        stat
 top

As shown above, the subsubcommands of perf kvm can come out now.

Signed-off-by: Yunlong Song <yunlong.song@...wei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@...hat.com>
Cc: Peter Zijlstra <a.p.zijlstra@...llo.nl>
Cc: Paul Mackerras <paulus@...ba.org>
Cc: Wang Nan <wangnan0@...wei.com>
Link: http://lkml.kernel.org/r/1426685758-25488-3-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@...hat.com>
---
 tools/perf/perf-completion.sh | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index 4822ed3..bbb61d0 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -100,6 +100,23 @@ __perfcomp_colon ()
 	__ltrim_colon_completions $cur
 }
 
+__perf_prev_skip_opts ()
+{
+	local i cmd_ cmds_
+
+	let i=cword-1
+	cmds_=$($cmd --list-cmds)
+	prev_skip_opts=()
+	while [ $i -ge 0 ]; do
+		for cmd_ in $cmds_; do
+			if [[ ${words[i]} == $cmd_ ]]; then
+				prev_skip_opts=${words[i]}
+				return
+			fi
+		done
+		((i--))
+	done
+}
 __perf_main ()
 {
 	local cmd
@@ -107,6 +124,8 @@ __perf_main ()
 	cmd=${words[0]}
 	COMPREPLY=()
 
+	# Skip options backward and find the last perf command
+	__perf_prev_skip_opts
 	# List perf subcommands or long options
 	if [ $cword -eq 1 ]; then
 		if [[ $cur == --* ]]; then
@@ -121,8 +140,8 @@ __perf_main ()
 		__perfcomp_colon "$evts" "$cur"
 	else
 		# List subcommands for perf commands
-		if [[ $prev == @(kvm|kmem|mem|lock|sched) ]]; then
-			subcmds=$($cmd $prev --list-cmds)
+		if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched) ]]; then
+			subcmds=$($cmd $prev_skip_opts --list-cmds)
 			__perfcomp_colon "$subcmds" "$cur"
 		fi
 		# List long option names
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists