Skip to content

Commit

Permalink
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 0 deletions.
1 change: 1 addition & 0 deletions completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ bashcomp_DATA = 2to3 \
kldload \
kldunload \
koji \
_kontena \
ktutil \
larch \
lastlog \
Expand Down
14 changes: 14 additions & 0 deletions completions/_kontena
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# 3rd party completion loader for kontena -*- shell-script -*-
#
# This serves as a fallback in case the completion is not installed otherwise.

# To avoid sourcing an empty string with `. "$(...)"` on failing to obtain the
# path, we assign the output to a variable `_comp_cmd_kontena__completion_path`
# and test it before sourcing. The variable is removed on successful loading
# but left on a failure for the debugging purpose.
_comp_cmd_kontena__completion_path=$("$1" whoami --bash-completion-path 2>/dev/null) &&
[[ -r $_comp_cmd_kontena__completion_path ]] &&
. "$_comp_cmd_kontena__completion_path" &&
unset -v _comp_cmd_kontena__completion_path

# ex: filetype=sh
1 change: 1 addition & 0 deletions test/fallback/completions/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ EXTRA_DIST = \
hwclock \
ionice \
keyring \
kontena \
look \
mdbook \
mock \
Expand Down
1 change: 1 addition & 0 deletions test/fallback/completions/kontena

0 comments on commit 5eef0ce

Please sign in to comment.