diff options
author | Oliver Kiddle <opk@zsh.org> | 2025-04-04 12:49:31 +0200 |
---|---|---|
committer | Oliver Kiddle <opk@zsh.org> | 2025-04-04 12:49:31 +0200 |
commit | 5858f6a12252eb82b7b5942e64dd8679854f0063 (patch) | |
tree | 537a162931b10a7abf4be6cea1d4b1cee14e1e54 | |
parent | e7163e69d90f8dcd5cdeea054df929b635f89260 (diff) | |
download | zsh-5858f6a12252eb82b7b5942e64dd8679854f0063.tar.gz zsh-5858f6a12252eb82b7b5942e64dd8679854f0063.zip |
53445: extra-verbose mode support on some recent Linux and BSD systems
-rw-r--r-- | ChangeLog | 5 | ||||
-rw-r--r-- | Completion/Unix/Type/_path_commands | 34 |
2 files changed, 32 insertions, 7 deletions
@@ -1,3 +1,8 @@ +2025-04-04 Oliver Kiddle <opk@zsh.org> + + * 53445: Completion/Unix/Type/_path_commands: extra-verbose mode + support on some recent Linux and BSD systems + 2025-03-31 Bart Schaefer <schaefer@toltec-ubuntu> * 53431: Src/params.c, Test/K01nameref.ztst: fix assignment via diff --git a/Completion/Unix/Type/_path_commands b/Completion/Unix/Type/_path_commands index 4d5a6c5af..59b146a88 100644 --- a/Completion/Unix/Type/_path_commands +++ b/Completion/Unix/Type/_path_commands @@ -24,13 +24,33 @@ return 1 } _call_whatis() { - case "$(whatis --version)" in - ("whatis from "*) - local -A args - zparseopts -D -A args s: r: - apropos "${args[-r]:-"$@"}" | fgrep "($args[-s]" + local sec impl variant sections=( 1 6 8 ) + case "$OSTYPE" in + (#i)dragonfly|(free|open)bsd*) impl=mandoc ;; + netbsd*) impl=apropos ;; + linux-gnu*) + sections=( 1 8 ) + # The same test as for man so has a good chance of being cached + _pick_variant -c man -r variant \ + freebsd='-S mansect' \ + openbsd='-S subsection' \ + $OSTYPE \ + --- + [[ $variant = $OSTYPE ]] && impl=man-db || impl=mandoc + ;; + esac + case $impl in + mandoc) + for sec in $sections; do + whatis -s $sec .\* + done + ;; + man-db) + whatis -s ${(j.,.)sections} -r .\* + ;; + apropos) + apropos -l ''|grep "([${(j..)sections}])" ;; - (*) whatis "$@";; esac } @@ -49,7 +69,7 @@ if zstyle -t ":completion:${curcontext}:" extra-verbose; then if ( [[ -n $first ]] || _cache_invalid command-descriptions ) && \ ! _retrieve_cache command-descriptions; then local line - for line in "${(f)$(_call_program command-descriptions _call_whatis -s 1 -r .\\\*\; _call_whatis -s 6 -r .\\\* 2>/dev/null)}"; do + for line in "${(f)$(_call_program command-descriptions _call_whatis)}"; do [[ -n ${line:#(#b)([^ ]#) #\([^ ]#\)( #\[[^ ]#\]|)[ -]#(*)} ]] && continue; [[ -z $match[1] || -z $match[3] || -z ${${match[1]}:#*:*} ]] && continue; _command_descriptions[$match[1]]=$match[3] |