Skip to content

Commit 683e4bf

Browse files
committed
Fix plugin completion parsing for plugins using ShellCompDirectiveFilterFileExt
Signed-off-by: Laura Brehm <laurabrehm@hey.com>
1 parent 88924b1 commit 683e4bf

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

contrib/completion/bash/docker

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1155,7 +1155,20 @@ __docker_complete_plugin() {
11551155
resultArray+=( "$value" )
11561156
fi
11571157
done
1158-
local result=$(eval "${resultArray[*]}" 2> /dev/null | grep -v '^:[0-9]*$')
1158+
local rawResult=$(eval "${resultArray[*]}" 2> /dev/null)
1159+
local result=$(grep -v '^:[0-9]*$' <<< "$rawResult")
1160+
1161+
# Compose V2 completions sometimes returns returns `:8` (ShellCompDirectiveFilterFileExt)
1162+
# with the expected file extensions (such as `yml`, `yaml`) to indicate that the shell should
1163+
# provide autocompletions for files with matching extensions
1164+
local completionFlag=$(tail -1 <<< "$rawResult")
1165+
if [ "$completionFlag" == ":8" ]; then
1166+
# format a valid glob pattern for the provided file extensions
1167+
local filePattern=$(tr '\n' '|' <<< "$result")
1168+
1169+
_filedir "$filePattern"
1170+
return
1171+
fi
11591172

11601173
# if result empty, just use filename completion as fallback
11611174
if [ -z "$result" ]; then

0 commit comments

Comments
 (0)