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: <20120807154555.GB12858@somewhere.redhat.com>
Date:	Tue, 7 Aug 2012 17:45:58 +0200
From:	Frederic Weisbecker <fweisbec@...il.com>
To:	David Ahern <dsahern@...il.com>
Cc:	Arnaldo Carvalho de Melo <acme@...stprotocols.net>,
	LKML <linux-kernel@...r.kernel.org>,
	Ingo Molnar <mingo@...nel.org>, Jiri Olsa <jolsa@...hat.com>,
	Namhyung Kim <namhyung@...il.com>,
	Peter Zijlstra <a.p.zijlstra@...llo.nl>,
	Stephane Eranian <eranian@...gle.com>
Subject: Re: [PATCH 0/2] perf tools: Basic bash completion support

On Tue, Aug 07, 2012 at 08:18:12AM -0600, David Ahern wrote:
> On 8/7/12 7:22 AM, Frederic Weisbecker wrote:
> >On Tue, Aug 07, 2012 at 03:19:44PM +0200, Frederic Weisbecker wrote:
> >>Hey,
> >>
> >>Basic bash completion support. Only support perf subcommands and most -e basic
> >>event descriptor (no grouping).
> >>
> >>I just have a small issue with tracepoints because of their ":" in the middle.
> >>It auto completes as long as we haven't yet reached the semicolon. Otherwise
> >>we need to add a double quote in the beginning of the expression. I'm quite
> >>a newbie in bash completion though, so I might find a subtelty later to solve
> >>this.
> >
> >Tips: for testing, you need to "make install" and update the bash completion
> >scripts:
> >
> >	# make install
> >	$ . /etc/bash_completion
> >
> 
> ANd you need to make sure the PATH hits the updated binary and not
> the default other wise you end up with:
> 
> /tmp/pbuild/perf recUnknown option: --list-cmds
> 
>  Usage: perf [--version] [--help] COMMAND [ARGS]
> Unknown option: --list-cmds
> 
> It's calling /usr/bin/perf with --list-cmds, versus the perf command
> I am running (/tmp/pbuild/perf). Any way to teach the completion to
> use the perf binary that the user is running?

Ah good point.

Does the below work for you? I'll respin with that change.

diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion
index 25f4d99..cba72a9 100644
--- a/tools/perf/bash_completion
+++ b/tools/perf/bash_completion
@@ -3,18 +3,20 @@
 have perf &&
 _perf()
 {
-	local cur
+	local cur cmd
 
 	COMPREPLY=()
 	_get_comp_words_by_ref cur prev
 
+	cmd=${COMP_WORDS[0]}
+
 	# List perf subcommands
 	if [ $COMP_CWORD -eq 1 ]; then
-		cmds=$(perf --list-cmds)
+		cmds=$($cmd --list-cmds)
 		COMPREPLY=( $( compgen -W '$cmds' -- "$cur" ) )
 	# List possible events for -e option
 	elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then
-		cmds=$(perf list --raw-dump)
+		cmds=$($cmd list --raw-dump)
 		COMPREPLY=( $( compgen -W '$cmds' -- $cur ) )
 	# Fall down to list regular files
 	else

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