Skip to content

Commit efba76c

Browse files
committed
Detect compose plugin
Signed-off-by: Ulysses Souza <[email protected]>
1 parent 385e5d7 commit efba76c

1 file changed

Lines changed: 11 additions & 9 deletions

File tree

contrib/completion/bash/docker

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5485,16 +5485,16 @@ _docker_wait() {
54855485
_docker_container_wait
54865486
}
54875487

5488+
COMPOSE_PLUGIN_PATH=$(docker info --format '{{json .ClientInfo.Plugins}}' | sed -n 's/.*"Path":"\([^"]\+docker-compose\)".*/\1/p')
5489+
54885490
_docker_compose() {
5489-
local composePluginPath="${HOME}/.docker/cli-plugins/docker-compose"
54905491
local completionCommand="__completeNoDesc"
5491-
local resultArray=(${composePluginPath} ${completionCommand} compose)
5492-
for value in "${words[@]:2}"
5493-
do
5494-
if [[ "${value}" == "" ]] ; then
5492+
local resultArray=($COMPOSE_PLUGIN_PATH $completionCommand compose)
5493+
for value in "${words[@]:2}"; do
5494+
if [ -z "$value" ]; then
54955495
resultArray+=( "''" )
54965496
else
5497-
resultArray+=( "${value}" )
5497+
resultArray+=( "$value" )
54985498
fi
54995499
done
55005500
local result=$(eval "${resultArray[*]}" 2> /dev/null)
@@ -5571,9 +5571,11 @@ _docker() {
55715571
wait
55725572
)
55735573

5574-
local known_plugin_commands=(
5575-
compose
5576-
)
5574+
local known_plugin_commands=()
5575+
5576+
if [ -f "$COMPOSE_PLUGIN_PATH" ] ; then
5577+
known_plugin_commands+=("compose")
5578+
fi
55775579

55785580
local experimental_server_commands=(
55795581
checkpoint

0 commit comments

Comments
 (0)