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]
Message-ID: <1426685758-25488-4-git-send-email-yunlong.song@huawei.com>
Date:	Wed, 18 Mar 2015 21:35:48 +0800
From:	Yunlong Song <yunlong.song@...wei.com>
To:	<a.p.zijlstra@...llo.nl>, <paulus@...ba.org>, <mingo@...hat.com>,
	<acme@...nel.org>
CC:	<linux-kernel@...r.kernel.org>, <wangnan0@...wei.com>
Subject: [PATCH 03/13] perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand

The bash completion gives wrong options for 'perf kvm|kmem|mem|lock|
sched subsubcommand --<TAB>', where 'kvm|kmem|mem|lock|sched' are all
subcommands of perf and 'subsubcommand' is a subcommand of 'kvm|kmem|mem
|lock|sched'. In fact, the result incorrectly lists the bash completion
of 'perf subcommand' rather than 'perf subcommand subsubcommand'.

Example:

Before this patch:

 $ perf kvm record --<TAB>
 --guest          --guestkallsyms  --guestmodules   --guestmount
 --guestvmlinux   --host           --input          --output
 --verbose

As shown above, the result is the options of kvm rather than record.

After this patch:

 $ perf kvm record --<TAB>
 --all-cpus          --cgroup            --delay             --group
 --no-buildid        --output            --quiet             --stat
 --uid
 --branch-any        --count             --event             --intr-regs
 --no-buildid-cache  --period            --raw-samples       --tid
 --verbose
 --branch-filter     --cpu               --filter            --mmap-pages
 --no-inherit        --per-thread        --realtime          --timestamp
 --weight
 --call-graph        --data              --freq
 --no-buffering      --no-samples        --pid
 --running-time      --transaction

As shown above, the result is exactly the options of record as we wished.

Signed-off-by: Yunlong Song <yunlong.song@...wei.com>
---
 tools/perf/perf-completion.sh | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh
index bbb61d0..01ce841 100644
--- a/tools/perf/perf-completion.sh
+++ b/tools/perf/perf-completion.sh
@@ -105,9 +105,12 @@ __perf_prev_skip_opts ()
 	local i cmd_ cmds_
 
 	let i=cword-1
-	cmds_=$($cmd --list-cmds)
+	cmds_=$($cmd $1 --list-cmds)
 	prev_skip_opts=()
 	while [ $i -ge 0 ]; do
+		if [[ ${words[i]} == $1 ]]; then
+			return
+		fi
 		for cmd_ in $cmds_; do
 			if [[ ${words[i]} == $cmd_ ]]; then
 				prev_skip_opts=${words[i]}
@@ -146,7 +149,9 @@ __perf_main ()
 		fi
 		# List long option names
 		if [[ $cur == --* ]];  then
-			subcmd=${words[1]}
+			subcmd=$prev_skip_opts
+			__perf_prev_skip_opts $subcmd
+			subcmd=$subcmd" "$prev_skip_opts
 			opts=$($cmd $subcmd --list-opts)
 			__perfcomp "$opts" "$cur"
 		fi
-- 
1.8.5.2

--
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

Powered by Openwall GNU/*/Linux Powered by OpenVZ