diff options
author | Namhyung Kim <namhyung.kim@lge.com> | 2012-10-04 01:23:54 -0400 |
---|---|---|
committer | Arnaldo Carvalho de Melo <acme@redhat.com> | 2012-10-04 11:44:52 -0400 |
commit | ae0c1f993411d88bf54c9e20a4249ebcc7a041f9 (patch) | |
tree | a7ba7fa86b502c573861bfa65f43da375cc89aa8 /tools | |
parent | e60fc847cefa34d9b7a60f8fbbe3f7dc68fbd75e (diff) |
perf tools: Complete tracepoint event names
Currently tracepoint events cannot be completed because they contain a
colon (:) character. The colon is considered as a word separator when
bash completion is done - variable COMP_WORDBREAKS contains colon - so
if a word being completed contains a colon it can be a problem.
Recent versions of bash completion provide -n switch to
_get_comp_words_by_ref and __ltrim_colon_completions functions in order
to resolve this issue. Copy the latter in case not exists.
Signed-off-by: Namhyung Kim <namhyung@kernel.org>
Cc: David Ahern <dsahern@gmail.com>
Cc: Frederic Weisbecker <fweisbec@gmail.com>
Cc: Ingo Molnar <mingo@kernel.org>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Link: http://lkml.kernel.org/r/1349328234-16995-1-git-send-email-namhyung@kernel.org
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/perf/bash_completion | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/tools/perf/bash_completion b/tools/perf/bash_completion index 5c355ababf80..56e6a12aab59 100644 --- a/tools/perf/bash_completion +++ b/tools/perf/bash_completion | |||
@@ -6,6 +6,19 @@ function_exists() | |||
6 | return $? | 6 | return $? |
7 | } | 7 | } |
8 | 8 | ||
9 | function_exists __ltrim_colon_completions || | ||
10 | __ltrim_colon_completions() | ||
11 | { | ||
12 | if [[ "$1" == *:* && "$COMP_WORDBREAKS" == *:* ]]; then | ||
13 | # Remove colon-word prefix from COMPREPLY items | ||
14 | local colon_word=${1%${1##*:}} | ||
15 | local i=${#COMPREPLY[*]} | ||
16 | while [[ $((--i)) -ge 0 ]]; do | ||
17 | COMPREPLY[$i]=${COMPREPLY[$i]#"$colon_word"} | ||
18 | done | ||
19 | fi | ||
20 | } | ||
21 | |||
9 | have perf && | 22 | have perf && |
10 | _perf() | 23 | _perf() |
11 | { | 24 | { |
@@ -13,9 +26,9 @@ _perf() | |||
13 | 26 | ||
14 | COMPREPLY=() | 27 | COMPREPLY=() |
15 | if function_exists _get_comp_words_by_ref; then | 28 | if function_exists _get_comp_words_by_ref; then |
16 | _get_comp_words_by_ref cur prev | 29 | _get_comp_words_by_ref -n : cur prev |
17 | else | 30 | else |
18 | cur=$(_get_cword) | 31 | cur=$(_get_cword :) |
19 | prev=${COMP_WORDS[COMP_CWORD-1]} | 32 | prev=${COMP_WORDS[COMP_CWORD-1]} |
20 | fi | 33 | fi |
21 | 34 | ||
@@ -35,6 +48,7 @@ _perf() | |||
35 | elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then | 48 | elif [[ $prev == "-e" && "${COMP_WORDS[1]}" == @(record|stat|top) ]]; then |
36 | evts=$($cmd list --raw-dump) | 49 | evts=$($cmd list --raw-dump) |
37 | COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) | 50 | COMPREPLY=( $( compgen -W '$evts' -- "$cur" ) ) |
51 | __ltrim_colon_completions $cur | ||
38 | # List long option names | 52 | # List long option names |
39 | elif [[ $cur == --* ]]; then | 53 | elif [[ $cur == --* ]]; then |
40 | subcmd=${COMP_WORDS[1]} | 54 | subcmd=${COMP_WORDS[1]} |