summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_man17
2 files changed, 19 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 3e76c101f..66c9b50a0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2001-08-21  Bart Schaefer  <schaefer@zsh.org>
+
+	* users/4157 (plus workers/15674): Completion/Unix/Command/_man:
+	Better handling of section numbers.
+
 2001-08-20  Sven Wischnowsky  <wischnow@zsh.org>
 
 	* 15669: Completion/Base/Completer/_approximate,
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index 0bdd8db8b..3da15f9ba 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -22,9 +22,20 @@ _man() {
 
   mrd=(${^manpath/\%L/${LANG:-En_US.ASCII}}/mandb(N))
 
-  if [[ $words[2] = (<->*|1M|l|n) ]]; then
-    dirs=( $^manpath/(sman|man|cat)${words[2]}/ )
-    awk="\$2 == \"$words[2]\" {print \$1}"
+  local sect
+  if [[ $OSTYPE = solaris* ]]; then
+    sect=$words[$words[(i)-s]+1]
+  elif [[ -n ${sect:=$words[$words[(i)-S]+1]} || -n ${sect:=$MANSECT} ]]; then
+    if [[ $sect != ${sect::="${sect//:/|}"} ]]; then
+      sect="($sect)"
+    fi
+  elif (( CURRENT > 2 )); then
+    sect=$words[2]
+  fi
+
+  if [[ $sect = (<->*|1M|l|n) || $sect = \(*\|*\) ]]; then
+    dirs=( $^manpath/(sman|man|cat)${~sect}/ )
+    awk="\$2 == \"$sect\" {print \$1}"
   else
     dirs=( $^manpath/(sman|man|cat)*/ )
     awk='{print $1}'