Skip to content

Commit 8610d7d

Browse files
committed
feat(rustup): add fallback 3rd party completion loader
1 parent d27b144 commit 8610d7d

File tree

4 files changed

+20
-0
lines changed

4 files changed

+20
-0
lines changed

completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,7 @@ bashcomp_DATA = 2to3 \
377377
_rtcwake \
378378
_ruff \
379379
_runuser \
380+
_rustup \
380381
sbcl \
381382
sbopkg \
382383
screen \

completions/_rustup

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# 3rd party completion loader for rustup -*- shell-script -*-
2+
#
3+
# This serves as a fallback in case the completion is not installed otherwise.
4+
5+
# shellcheck disable=SC2168 # "local" is ok, assume sourced by __load_completion
6+
local _comp__load_3rdparty_reset_shopt=$(shopt -po posix)
7+
set +o posix
8+
9+
. <("$1" completions bash rustup 2>/dev/null)
10+
11+
$_comp__load_3rdparty_reset_shopt
12+
13+
{
14+
complete -p "$1" || complete -p "${1##*/}"
15+
} &>/dev/null
16+
17+
# ex: filetype=sh

test/fallback/completions/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ EXTRA_DIST = \
2525
rtcwake \
2626
ruff \
2727
runuser \
28+
rustup \
2829
slackpkg \
2930
su \
3031
svn \

test/fallback/completions/rustup

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

0 commit comments

Comments
 (0)