Skip to content

File tree

4 files changed

+17
-0
lines changed

4 files changed

+17
-0
lines changed

completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,7 @@ bashcomp_DATA = 2to3 \
216216
kldload \
217217
kldunload \
218218
koji \
219+
_kontena \
219220
ktutil \
220221
larch \
221222
lastlog \

completions/_kontena

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# 3rd party completion loader for kontena -*- shell-script -*-
2+
#
3+
# This serves as a fallback in case the completion is not installed otherwise.
4+
5+
# To avoid sourcing an empty string with `. "$(...)"` on failing to obtain the
6+
# path, we assign the output to a variable `_comp_cmd_kontena__completion_path`
7+
# and test it before sourcing. The variable is removed on successful loading
8+
# but left on a failure for the debugging purpose.
9+
_comp_cmd_kontena__completion_path=$("$1" whoami --bash-completion-path 2>/dev/null) &&
10+
[[ -r $_comp_cmd_kontena__completion_path ]] &&
11+
. "$_comp_cmd_kontena__completion_path" &&
12+
unset -v _comp_cmd_kontena__completion_path
13+
14+
# ex: filetype=sh

test/fallback/completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ EXTRA_DIST = \
1515
hwclock \
1616
ionice \
1717
keyring \
18+
kontena \
1819
look \
1920
mdbook \
2021
mock \

test/fallback/completions/kontena

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../completions/_kontena

0 commit comments

Comments
 (0)