diff options
| author | 魏曹先生 <1992414357@qq.com> | 2026-08-07 16:57:14 +0800 |
|---|---|---|
| committer | 魏曹先生 <1992414357@qq.com> | 2026-08-07 16:57:14 +0800 |
| commit | 7d86338c64a1761ac8db8b1977fcfd6912ae71ce (patch) | |
| tree | f37fa854966ba4c78e11ff0a0554c3ad1f2561eb | |
| parent | 815cc96a09b86eb890d6fa36d9afe8ed18afb867 (diff) | |
fix(zsh): guard compdef call with function check
If compdef is not available, fall back to compctl
directly without invoking an undefined command.
| -rw-r--r-- | mingling_core/tmpls/comps/zsh.zsh | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/mingling_core/tmpls/comps/zsh.zsh b/mingling_core/tmpls/comps/zsh.zsh index f665133..7cf5f7b 100644 --- a/mingling_core/tmpls/comps/zsh.zsh +++ b/mingling_core/tmpls/comps/zsh.zsh @@ -61,8 +61,11 @@ _<<<bin_name>>>_completion() { fi } -compdef _<<<bin_name>>>_completion <<<bin_name>>> - -if [[ $? -ne 0 ]]; then +if (( $+functions[compdef] )); then + compdef _<<<bin_name>>>_completion <<<bin_name>>> + if [[ $? -ne 0 ]]; then + compctl -K _<<<bin_name>>>_completion <<<bin_name>>> + fi +else compctl -K _<<<bin_name>>>_completion <<<bin_name>>> fi |
