Skip to content

Commit

Permalink
Merge pull request #1102 from akinomyoga/fix-gdb-posix
Browse files Browse the repository at this point in the history
fix(gdb): use POSIX-compatible find expression
  • Loading branch information
scop authored Feb 8, 2024
2 parents ca8e240 + 532fc05 commit 79423f0
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions completions/gdb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ _comp_cmd_gdb()

# gdb [options] [executable-file [core-file or process-id]]
if ((cword == 1)); then
local IFS
compopt -o filenames
if _comp_looks_like_path "$cur"; then
# compgen -c works as expected if $cur contains any slashes.
Expand All @@ -26,11 +25,13 @@ _comp_cmd_gdb()
# functions and aliases. Thus we need to retrieve the program
# names manually.
local path_array
_comp_compgen -Rv path_array split -F : -X '' -- "$PATH"
_comp_compgen -Rv path_array split -F : -X '' -S /. -- "$PATH"
_comp_compgen_split -o plusdirs -- "$(
find ${path_array[@]+"${path_array[@]}"} . -mindepth 1 \
-maxdepth 1 -not -type d -executable -printf '%f\n' \
2>/dev/null
# 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
Expand Down

0 comments on commit 79423f0

Please sign in to comment.