fix(completions/django): Check Existence of binary

This commit is contained in:
Koichi Murase
2023-04-16 17:08:27 +09:00
parent 7965543018
commit 3a5b36d614

View File

@@ -55,17 +55,16 @@ function _omb_completion_django_python {
function _omb_completion_django_init { function _omb_completion_django_init {
# Support for multiple interpreters. # Support for multiple interpreters.
local -a pythons=() local -a pythons=(python)
if _omb_util_command_exists whereis; then if _omb_util_command_exists whereis; then
local python_interpreters local python_interpreters
_omb_util_split python_interpreters "$(whereis python | cut -d " " -f 2-)" _omb_util_split python_interpreters "$(whereis python | cut -d " " -f 2-)"
local python local python
for python in "${python_interpreters[@]}"; do for python in "${python_interpreters[@]}"; do
[[ -x $python ]] || continue
pythons+=("$(basename -- "$python")") pythons+=("$(basename -- "$python")")
done done
_omb_util_split pythons "$(printf '%s\n' "${pythons[@]}" | sort -u)" $'\n' _omb_util_split pythons "$(printf '%s\n' "${pythons[@]}" | sort -u)" $'\n'
else
pythons=(python)
fi fi
complete -F _omb_completion_django_python -o default "${pythons[@]}" complete -F _omb_completion_django_python -o default "${pythons[@]}"