Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

perf tools: Add the bash completion for listing subsubcommands of perf timechart

The bash completion does not support listing subsubcommands for 'perf
timechart <TAB>', so fix it.

Example:

Before this patch:

$ perf timechart <TAB>
$

As shown above, the subsubcommands of perf timechart does not come out.

After this patch:

$ perf timechart <TAB>
record

As shown above, the subsubcommands of perf timechart can come out now.

Signed-off-by: Yunlong Song <yunlong.song@huawei.com>
Tested-by: Arnaldo Carvalho de Melo <acme@redhat.com>
Cc: Paul Mackerras <paulus@samba.org>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Wang Nan <wangnan0@huawei.com>
Link: http://lkml.kernel.org/r/1426685758-25488-12-git-send-email-yunlong.song@huawei.com
Signed-off-by: Arnaldo Carvalho de Melo <acme@redhat.com>

authored by

Yunlong Song and committed by
Arnaldo Carvalho de Melo
33ec0caf 1f9975f1

+5 -4
+4 -3
tools/perf/builtin-timechart.c
··· 1958 1958 parse_time), 1959 1959 OPT_END() 1960 1960 }; 1961 - const char * const timechart_usage[] = { 1961 + const char * const timechart_subcommands[] = { "record", NULL }; 1962 + const char *timechart_usage[] = { 1962 1963 "perf timechart [<options>] {record}", 1963 1964 NULL 1964 1965 }; ··· 1977 1976 "perf timechart record [<options>]", 1978 1977 NULL 1979 1978 }; 1980 - argc = parse_options(argc, argv, timechart_options, timechart_usage, 1981 - PARSE_OPT_STOP_AT_NON_OPTION); 1979 + argc = parse_options_subcommand(argc, argv, timechart_options, timechart_subcommands, 1980 + timechart_usage, PARSE_OPT_STOP_AT_NON_OPTION); 1982 1981 1983 1982 if (tchart.power_only && tchart.tasks_only) { 1984 1983 pr_err("-P and -T options cannot be used at the same time.\n");
+1 -1
tools/perf/perf-completion.sh
··· 143 143 __perfcomp_colon "$evts" "$cur" 144 144 else 145 145 # List subcommands for perf commands 146 - if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test) ]]; then 146 + if [[ $prev_skip_opts == @(kvm|kmem|mem|lock|sched|data|help|script|test|timechart) ]]; then 147 147 subcmds=$($cmd $prev_skip_opts --list-cmds) 148 148 __perfcomp_colon "$subcmds" "$cur" 149 149 fi