From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752367AbbCVKKL (ORCPT ); Sun, 22 Mar 2015 06:10:11 -0400 Received: from terminus.zytor.com ([198.137.202.10]:57066 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751795AbbCVKKG (ORCPT ); Sun, 22 Mar 2015 06:10:06 -0400 Date: Sun, 22 Mar 2015 03:09:47 -0700 From: tip-bot for Yunlong Song Message-ID: Cc: a.p.zijlstra@chello.nl, acme@redhat.com, yunlong.song@huawei.com, wangnan0@huawei.com, paulus@samba.org, tglx@linutronix.de, mingo@kernel.org, hpa@zytor.com, linux-kernel@vger.kernel.org Reply-To: hpa@zytor.com, linux-kernel@vger.kernel.org, wangnan0@huawei.com, yunlong.song@huawei.com, tglx@linutronix.de, paulus@samba.org, mingo@kernel.org, acme@redhat.com, a.p.zijlstra@chello.nl In-Reply-To: <1426685758-25488-4-git-send-email-yunlong.song@huawei.com> References: <1426685758-25488-4-git-send-email-yunlong.song@huawei.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:perf/core] perf tools: Provide the right bash completion for listing options of perf subcommand subsubcommand Git-Commit-ID: eee200a6c4a9712146ba999f944ba4f2c3fc2d44 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: eee200a6c4a9712146ba999f944ba4f2c3fc2d44 Gitweb: http://git.kernel.org/tip/eee200a6c4a9712146ba999f944ba4f2c3fc2d44 Author: Yunlong Song AuthorDate: Wed, 18 Mar 2015 21:35:48 +0800 Committer: Arnaldo Carvalho de Melo CommitDate: Thu, 19 Mar 2015 13:49:28 -0300 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 --', 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 -- --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 -- --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 Tested-by: Arnaldo Carvalho de Melo Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1426685758-25488-4-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- 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