[PATCH 3/3] perf, tools: Fix completion script to handle comma list
From: Andi Kleen The perf event completion script only handled a single event per -e option. So for "perf stat -e cycles,branches" branches could not be completed. Fix that issue by always only using the last suffix for completion. For some reason it only works in bash currently, but zsh is the same as before. v2: Handle conflict with upper case completion patch Signed-off-by: Andi Kleen --- tools/perf/perf-completion.sh | 4 1 file changed, 4 insertions(+) diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index 72391ff68f66..582513e004f9 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -166,7 +166,11 @@ __perf_main () [[:upper:]]*) evts=$($cmd list --raw-dump vendor | tr a-z A-Z) ;; *) evts=$($cmd list --raw-dump) ;; esac + old="$cur" + cur="${cur/*[,{]/}" + prefix=${old%$cur} __perfcomp_colon "$evts" "$cur" + COMPREPLY=("${prefix}${COMPREPLY[0]}") else # List subcommands for perf commands if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched| -- 2.5.5
Re: [PATCH 3/3] perf, tools: Fix completion script to handle comma list
On Thu, Oct 06, 2016 at 05:29:44PM -0300, Arnaldo Carvalho de Melo wrote: > Em Thu, Oct 06, 2016 at 01:08:39PM -0700, Andi Kleen escreveu: > > > perf stat -e CPL_CYCLES.RING0 > > > > > > but if I try: > > > > > > perf stat -e cycles,CPL > > > > > > I get nothing :-\ > > > > > > Is this working with you? > > > > You can't mix cases like this, the upper case patch doesn't support that. > > It's either all upper or all lower case. > > > > If you continue with lower case it should work. > > I understand that this should be a limitation of the current patch, but > if we decide to support completion after a comma, I think people will > expect that all events will be available :-\ I don't see a simple way to do it. I'm not gonna write a complex parser in shell. If that really is a requirement the patch has to be withdrawn. -Andi
Re: [PATCH 3/3] perf, tools: Fix completion script to handle comma list
Em Thu, Oct 06, 2016 at 01:08:39PM -0700, Andi Kleen escreveu: > > perf stat -e CPL_CYCLES.RING0 > > > > but if I try: > > > > perf stat -e cycles,CPL > > > > I get nothing :-\ > > > > Is this working with you? > > You can't mix cases like this, the upper case patch doesn't support that. > It's either all upper or all lower case. > > If you continue with lower case it should work. I understand that this should be a limitation of the current patch, but if we decide to support completion after a comma, I think people will expect that all events will be available :-\ - Arnaldo
Re: [PATCH 3/3] perf, tools: Fix completion script to handle comma list
> perf stat -e CPL_CYCLES.RING0 > > but if I try: > > perf stat -e cycles,CPL > > I get nothing :-\ > > Is this working with you? You can't mix cases like this, the upper case patch doesn't support that. It's either all upper or all lower case. If you continue with lower case it should work. -Andi
Re: [PATCH 3/3] perf, tools: Fix completion script to handle comma list
Em Thu, Oct 06, 2016 at 12:23:27PM -0700, Andi Kleen escreveu: > From: Andi Kleen > > The perf event completion script only handled a single event per > -e option. So for "perf stat -e cycles,branches" branches could > not be completed. > > Fix that issue by always only using the last suffix for completion. > > For some reason it only works in bash currently, but zsh > is the same as before. It works partially, for instance, if I try completing: perf stat -e CPL I get: perf stat -e CPL_CYCLES.RING0 but if I try: perf stat -e cycles,CPL I get nothing :-\ Is this working with you? > v2: Handle conflict with upper case completion patch > Signed-off-by: Andi Kleen > --- > tools/perf/perf-completion.sh | 4 > 1 file changed, 4 insertions(+) > > diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh > index 3b5a258a4b7b..819a1346689f 100644 > --- a/tools/perf/perf-completion.sh > +++ b/tools/perf/perf-completion.sh > @@ -166,7 +166,11 @@ __perf_main () > [[:upper:]]*) evts=$($cmd list --raw-dump json | tr a-z > A-Z) ;; > *) evts=$($cmd list --raw-dump) ;; > esac > + old="$cur" > + cur="${cur/*[,{]/}" > + prefix=${old%$cur} > __perfcomp_colon "$evts" "$cur" > + COMPREPLY=("${prefix}${COMPREPLY[0]}") > else > # List subcommands for perf commands > if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched| > -- > 2.5.5
[PATCH 3/3] perf, tools: Fix completion script to handle comma list
From: Andi Kleen The perf event completion script only handled a single event per -e option. So for "perf stat -e cycles,branches" branches could not be completed. Fix that issue by always only using the last suffix for completion. For some reason it only works in bash currently, but zsh is the same as before. v2: Handle conflict with upper case completion patch Signed-off-by: Andi Kleen --- tools/perf/perf-completion.sh | 4 1 file changed, 4 insertions(+) diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index 3b5a258a4b7b..819a1346689f 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -166,7 +166,11 @@ __perf_main () [[:upper:]]*) evts=$($cmd list --raw-dump json | tr a-z A-Z) ;; *) evts=$($cmd list --raw-dump) ;; esac + old="$cur" + cur="${cur/*[,{]/}" + prefix=${old%$cur} __perfcomp_colon "$evts" "$cur" + COMPREPLY=("${prefix}${COMPREPLY[0]}") else # List subcommands for perf commands if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched| -- 2.5.5