diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 01:03:19 +0000 |
commit | 6c09f2a45c5541e9c207d14fc7aa21a4a0066bde (patch) | |
tree | 0221189d367bf661f6f9493c4f17a03f0dd4b7d2 /completions/gdb | |
parent | Releasing progress-linux version 1:2.11-8~progress7.99u1. (diff) | |
download | bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.tar.xz bash-completion-6c09f2a45c5541e9c207d14fc7aa21a4a0066bde.zip |
Merging upstream version 1:2.12.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'completions/gdb')
-rw-r--r-- | completions/gdb | 41 |
1 files changed, 20 insertions, 21 deletions
diff --git a/completions/gdb b/completions/gdb index f78f8a5..e6a124f 100644 --- a/completions/gdb +++ b/completions/gdb @@ -1,47 +1,46 @@ # bash completion for gdb -*- shell-script -*- -_gdb() +_comp_cmd_gdb() { - local cur prev words cword i - _init_completion || return + local cur prev words cword comp_args i + _comp_initialize -- "$@" || return # gdb [options] --args executable-file [inferior-arguments ...] for ((i = 1; i < cword; i++)); do if [[ ${words[i]} == --args ]]; then - _command_offset $((i + 1)) + _comp_command_offset $((i + 1)) return $? fi done # gdb [options] [executable-file [core-file or process-id]] if ((cword == 1)); then - local IFS compopt -o filenames - if [[ $cur == */* ]]; then + if _comp_looks_like_path "$cur"; then # compgen -c works as expected if $cur contains any slashes. - IFS=$'\n' - COMPREPLY=($(PATH="$PATH:." compgen -d -c -- "$cur")) + local PATH="$PATH:." + _comp_compgen_commands else # otherwise compgen -c contains Bash's built-in commands, # functions and aliases. Thus we need to retrieve the program # names manually. - IFS=":" - local path_array=($( - command sed -e 's/:\{2,\}/:/g' -e 's/^://' -e 's/:$//' <<<"$PATH" - )) - IFS=$'\n' - COMPREPLY=($(compgen -d -W '$(find "${path_array[@]}" . \ - -mindepth 1 -maxdepth 1 -not -type d -executable \ - -printf "%f\\n" 2>/dev/null)' -- "$cur")) + local path_array + _comp_compgen -Rv path_array split -F : -X '' -S /. -- "$PATH" + _comp_compgen_split -o plusdirs -- "$( + # Note: ${v+"$@"} does not work with empty IFS in bash < 4.4 + IFS=$' \t\n' + find ${path_array[@]+"${path_array[@]}"} . -name . -o \ + -type d -prune -o -perm -u+x -print 2>/dev/null | + command sed 's|^.*/||' | sort -u + )" fi elif ((cword == 2)); then - COMPREPLY=($(compgen -W "$(command ps axo comm,pid | - awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" -- "$cur")) + _comp_compgen_split -- "$(command ps axo comm,pid | + _comp_awk '{if ($1 ~ /^'"${prev##*/}"'/) print $2}')" compopt -o filenames - COMPREPLY+=($(compgen -f -X '!?(*/)core?(.?*)' -o plusdirs \ - -- "$cur")) + _comp_compgen -a -- -f -X '!?(*/)core?(.?*)' -o plusdirs fi } && - complete -F _gdb gdb + complete -F _comp_cmd_gdb gdb # ex: filetype=sh |