Skip to content

Commit 70a0817

Browse files
Expand zsh compdef patterns (#311)
* Expand zsh compdef patterns * Fix zsh bridge losing 85% of completers due to bare #compdef aborting the glob loop Lines like "#compdef -value-,DISPLAY,-default-" were reduced to a bare "#compdef" by the sed option-stripping step. This reached the while loop, matched the glob-character check, and caused an invalid pattern error that aborted the entire loop, dropping all subsequent entries. Filter these bare #compdef strings before the loop so glob expansion runs to completion. Assisted-by: Crush:glm-5.2 * Isolate glob expansion in subshell to contain malformed patterns A bare #compdef was one bad pattern that aborted the while loop, but malformed globs like unmatched parens or brackets from other zsh completion packages could cause the same failure. Running the expansion in a subshell with stderr suppressed ensures any bad pattern only skips that single entry instead of aborting the entire loop. Assisted-by: Crush:glm-5.2 --------- Co-authored-by: rsteube-bot <rsteube-bot@users.noreply.github.com>
1 parent 093178b commit 70a0817

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

pkg/bridges/zsh.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
setopt extendedglob
2+
13
printf '%s\n' $fpath \
24
| xargs -I{} find -L {} -name '_*' 2>/dev/null \
35
| xargs head -n1 2>/dev/null \
@@ -12,11 +14,16 @@ printf '%s\n' $fpath \
1214
| grep -v \
1315
-e '^$' \
1416
-e '=' \
15-
-e '\[' \
16-
-e '\*' \
17-
-e '#' \
1817
-e '^_' \
1918
-e '^-' \
2019
-e '^.$' \
20+
-e '^#compdef$' \
21+
| while IFS= read -r compdef; do
22+
if [[ "$compdef" == *[\[\]\*\#\(\)\|]* ]]; then
23+
(print -rl -- ${(M)${(k)commands}:#${~compdef}}) 2>/dev/null
24+
else
25+
print -r -- "$compdef"
26+
fi
27+
done \
2128
| sort \
2229
| uniq

0 commit comments

Comments
 (0)