Skip to content

Commit cae8710

Browse files
author
Alexander Obuhovich
committed
Check for "bash-completion" package before defining hook in Bash
1 parent c7b9c45 commit cae8710

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/HookFactory.php

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,13 @@ function %%function_name%% {
6464
__ltrim_colon_completions "$cur";
6565
};
6666
67-
complete -F %%function_name%% "%%program_name%%";
67+
COMP_FOUND=`type -t _get_comp_words_by_ref`
68+
69+
if [ "$COMP_FOUND" == "function" ]; then
70+
complete -F %%function_name%% "%%program_name%%";
71+
else
72+
echo "The 'bash-completion' package not found."
73+
fi
6874
END
6975

7076
// ZSH Hook
@@ -169,7 +175,7 @@ protected function generateFunctionName($programPath, $programName)
169175

170176
/**
171177
* Make a string safe for use as a shell function name
172-
*
178+
*
173179
* @param string $name
174180
* @return string
175181
*/

0 commit comments

Comments
 (0)