1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
|
# bash completion of bpftrace(8)
_bpftrace_filedir()
{
# bash-completion 2.11-1091-g6e8a1546bde2 rename _filedir to _comp_compgen_filedir
if [[ ${BASH_COMPLETION_VERSINFO[0]} == 2 ]] && \
[[ ${BASH_COMPLETION_VERSINFO[1]} > 11 ]]; then
_comp_compgen_filedir "${@}"
else
_filedir "${@}"
fi
}
_bpftrace()
{
local cur prev words argument
_init_completion -- "$@" || return
local all_args='-B -f -o -e -h --help -I --include -l -p -c
--usdt-file-activation --unsafe -q --info -k
-V --version --no-warnings -v --dry-run -d
--emit-elf --emit-llvm'
if [[ $cur == -* ]]; then
argument=$cur
fi
case ${prev} in
-B)
COMPREPLY=( $(compgen -W "line full none" -- ${cur}) )
return 0
;;
-f)
COMPREPLY=( $(compgen -W "text json" -- ${cur}) )
return 0
;;
-c)
COMPREPLY=( $(compgen -c -- ${cur}) )
return 0
;;
-o | --include | --emit-elf | --emit-llvm)
_bpftrace_filedir
return 0
;;
-I)
_bpftrace_filedir -d
return 0
;;
-p)
local PIDS=$(cd /proc && echo [0-9]*)
COMPREPLY=( $(compgen -W "$PIDS" -- ${cur}) )
return 0
;;
-d)
COMPREPLY=( $(compgen -W "all ast codegen codegen-opt dis libbpf verifier" -- ${cur}) )
return 0
;;
-h | --help | -V | --version | --info)
return
;;
esac
# bpftrace directly specifies the script, like: bpftrace a.bt
if [[ ! ${argument} ]]; then
_bpftrace_filedir
else
# Just drop -e content completion, because it's very complex.
if ([[ ${cur} == -* ]] || [[ -z ${cur} ]]) && [[ ${prev} != -e ]]; then
COMPREPLY=( $(compgen -W "${all_args}" -- ${cur}) )
return
fi
fi
}
complete -F _bpftrace bpftrace
|