Skip to content

Commit

Permalink
fix(gdb): use POSIX-compatible find expression
Browse files Browse the repository at this point in the history
We here use the technique for "-mindepth 1 -maxdepth 1" explained in

https://unix.stackexchange.com/a/330372/121088

We first suffix "/." to each directory name, and skip the top level
directory by "-name . -o".  Then we skip the level-1 directories and
their contents with "-type -d -prune -o".  Finally we check the
permission and print the files.
  • Loading branch information
akinomyoga committed Feb 8, 2024
1 parent 41236da commit 73938cd
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions completions/gdb
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +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 -- "$(
# Note: ${v+"$@"} does not work with empty IFS in bash < 4.4
IFS=$' \t\n'
find ${path_array[@]+"${path_array[@]}"} . -mindepth 1 \
-maxdepth 1 -not -type d -executable -printf '%f\n' \
2>/dev/null
find ${path_array[@]+"${path_array[@]}"} . -name . -o \
-type d -prune -o -perm -u+x -print 2>/dev/null |
command sed 's|^.*/||'
)"
fi
elif ((cword == 2)); then
Expand Down

1 comment on commit 73938cd

@Kobaxidze256
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based and POSIXpilled

Please sign in to comment.