summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOliver Kiddle <opk@zsh.org>2025-04-04 12:49:31 +0200
committerOliver Kiddle <opk@zsh.org>2025-04-04 12:49:31 +0200
commit5858f6a12252eb82b7b5942e64dd8679854f0063 (patch)
tree537a162931b10a7abf4be6cea1d4b1cee14e1e54
parente7163e69d90f8dcd5cdeea054df929b635f89260 (diff)
downloadzsh-5858f6a12252eb82b7b5942e64dd8679854f0063.tar.gz
zsh-5858f6a12252eb82b7b5942e64dd8679854f0063.zip
53445: extra-verbose mode support on some recent Linux and BSD systems
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Type/_path_commands34
2 files changed, 32 insertions, 7 deletions
diff --git a/ChangeLog b/ChangeLog
index af75d0ea7..24c02959c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -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]