Refactor "{declare -{f,F} => _omb_util_function_exists}"

Co-authored-by: Koichi Murase <myoga.murase@gmail.com>
This commit is contained in:
M
2022-01-23 12:27:11 -08:00
committed by Koichi Murase
parent 4fb778c405
commit b893ce6f79
8 changed files with 12 additions and 12 deletions

View File

@@ -552,7 +552,7 @@ _docker_compose() {
done
local completions_func=_docker_compose_${command//-/_}
declare -F $completions_func >/dev/null && $completions_func
_omb_util_function_exists $completions_func && $completions_func
eval "$previous_extglob_setting"
return 0

View File

@@ -243,7 +243,7 @@ _docker_machine() {
done
local completion_func=_docker_machine_"${command//-/_}"
if declare -F "${completion_func}" > /dev/null; then
if _omb_util_function_exists "${completion_func}"; then
${completion_func}
fi

View File

@@ -394,7 +394,7 @@ __docker_subcommands() {
subcommand_pos=$counter
local subcommand=${words[$counter]}
local completions_func=_docker_${command}_${subcommand}
declare -F $completions_func >/dev/null && $completions_func
_omb_util_function_exists $completions_func && $completions_func
return 0
;;
esac
@@ -2953,7 +2953,7 @@ _docker() {
fi
local completions_func=_docker_${command}
declare -F $completions_func >/dev/null && $completions_func
_omb_util_function_exists $completions_func && $completions_func
eval "$previous_extglob_setting"
return 0

View File

@@ -3,7 +3,7 @@
# This script complements the completion script that ships with git.
# Check that git tab completion is available
if declare -F _git > /dev/null; then
if _omb_util_function_exists _git; then
# Duplicate and rename the 'list_all_commands' function
eval "$(declare -f __git_list_all_commands | \
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"

View File

@@ -3,12 +3,12 @@
# This script complements the completion script that ships with git.
# If there is no git tab completion, but we have the _completion loader try to load it
if ! declare -F _git > /dev/null && declare -F _completion_loader > /dev/null; then
if ! _omb_util_function_exists _git && _omb_util_function_exists _completion_loader; then
_completion_loader git
fi
# Check that git tab completion is available
if declare -F _git > /dev/null; then
if _omb_util_function_exists _git; then
# Duplicate and rename the 'list_all_commands' function
eval "$(declare -f __git_list_all_commands | \
sed 's/__git_list_all_commands/__git_list_all_commands_without_hub/')"

View File

@@ -6,7 +6,7 @@
function_exists()
{
declare -F $1 > /dev/null
_omb_util_function_exists $1
return $?
}
@@ -261,4 +261,4 @@ _mvn()
}
complete -o default -F _mvn -o nospace mvn
complete -o default -F _mvn -o nospace mvnDebug
complete -o default -F _mvn -o nospace mvnDebug

View File

@@ -130,7 +130,7 @@ _packer_completion ()
# Words containing an equal sign get split into tokens in bash > 4, which
# doesn't come in handy here.
# This is handled here. bash < 4 does not split.
declare -f _get_comp_words_by_ref >/dev/null && _get_comp_words_by_ref -n = cur
_omb_util_function_exists _get_comp_words_by_ref && _get_comp_words_by_ref -n = cur
COMPREPLY=()
local i c=1 command
@@ -157,7 +157,7 @@ _packer_completion ()
fi
local completion_func="__packer_${command}"
declare -f $completion_func >/dev/null && $completion_func
_omb_util_function_exists $completion_func && $completion_func
}
complete -o nospace -F _packer_completion packer

View File

@@ -77,7 +77,7 @@ _omb_theme_PROMPT_COMMAND() {
printf "\033]0;%s@%s:%s\007" "${USER}" "${HOSTNAME%%.*}" "${PWD/#$HOME/\~}"
# Open the new terminal in the same directory
declare -f __vte_osc7 > /dev/null && __vte_osc7
_omb_util_function_exists __vte_osc7 && __vte_osc7
PS1="${_omb_prompt_reset_color}[${DULCIE_USER}@${DULCIE_HOST}$(scm_prompt_info)${_omb_prompt_reset_color} ${DULCIE_WORKINGDIR}]"
if [[ "${DULCIE_MULTILINE}" -eq "1" ]]; then