From 7335399a6a4bead9ef8b59ce7d811fc4e99ca98c Mon Sep 17 00:00:00 2001 From: Yunlong Song Date: Fri, 27 Feb 2015 18:21:31 +0800 Subject: perf tools: Fix the bash completion problem of 'perf --*' The perf-completion.sh uses a predefined string '--help --version --exec-path --html-path --paginate --no-pager --perf-dir --work-tree --debugfs-dir' for the bash completion of 'perf --*', which has two problems: Problem 1: If the options of perf are changed (see handle_options() in perf.c), the perf-completion.sh has to be changed at the same time. If not, the bash completion of 'perf --*' and the options which perf really supports will be inconsistent. Problem 2: When typing another single character after 'perf --', e.g. 'h', and hit TAB key to get the bash completion of 'perf --h', the character 'h' disappears at once. This is not what we want, we wish the bash completion can return '--help --html-path' and then we can continue to choose one. To solve this problem, we add '--list-opts' to perf, which now supports 'perf --list-opts' directly, and its result can be used in bash completion now. Example: Before this patch: $ perf --h <-- hit TAB key after character 'h' $ perf -- <-- 'h' disappears and no required result After this patch: $ perf --h <-- hit TAB key after character 'h' --help --html-path <-- the required result Signed-off-by: Yunlong Song Tested-by: Arnaldo Carvalho de Melo Cc: Ingo Molnar Cc: Paul Mackerras Cc: Peter Zijlstra Cc: Wang Nan Link: http://lkml.kernel.org/r/1425032491-20224-8-git-send-email-yunlong.song@huawei.com Signed-off-by: Arnaldo Carvalho de Melo --- tools/perf/perf-completion.sh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'tools/perf/perf-completion.sh') diff --git a/tools/perf/perf-completion.sh b/tools/perf/perf-completion.sh index 33569847fdcc..c2595e9bd69b 100644 --- a/tools/perf/perf-completion.sh +++ b/tools/perf/perf-completion.sh @@ -110,13 +110,11 @@ __perf_main () # List perf subcommands or long options if [ $cword -eq 1 ]; then if [[ $cur == --* ]]; then - __perfcomp '--help --version \ - --exec-path --html-path --paginate --no-pager \ - --perf-dir --work-tree --debugfs-dir' -- "$cur" + cmds=$($cmd --list-opts) else cmds=$($cmd --list-cmds) - __perfcomp "$cmds" "$cur" fi + __perfcomp "$cmds" "$cur" # List possible events for -e option elif [[ $prev == "-e" && "${words[1]}" == @(record|stat|top) ]]; then evts=$($cmd list --raw-dump) -- cgit v1.2.3