From 3099d7bdebd12295e485115f89234808c203669d Mon Sep 17 00:00:00 2001 From: Pascal Huber Date: Sun, 19 Sep 2021 17:18:57 +0200 Subject: [PATCH] Fix man completion for BSD's mandoc --- share/functions/__fish_complete_man.fish | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/share/functions/__fish_complete_man.fish b/share/functions/__fish_complete_man.fish index 057b298c0..5f19aa2f1 100644 --- a/share/functions/__fish_complete_man.fish +++ b/share/functions/__fish_complete_man.fish @@ -35,15 +35,13 @@ function __fish_complete_man __fish_apropos $token 2>/dev/null | awk ' BEGIN { FS="[\t ]- "; OFS="\t"; } # BSD/Darwin - /^[^( \t]+\('$section'\)/ { - split($1, pages, ", "); + /^[^( \t]+(, [^( \t]+)*\('$section'\)/ { + paren = index($1, "("); + sect = substr($1, paren + 1, length($1) - paren - 1); + aliases = substr($1, 1, paren - 1) + split(aliases, pages, ", "); for (i in pages) { - page = pages[i]; - sub(/[ \t]+/, "", page); - paren = index(page, "("); - name = substr(page, 1, paren - 1); - sect = substr(page, paren + 1, length(page) - paren - 1); - print name, sect ": " $2; + print pages[i], sect ": " $2 } } # man-db