summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-07-31 12:36:55 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-08-01 21:15:47 +0000
commitf70615d878b80f9303f7e04daa11cef9e133ac3b (patch)
tree04e388b4dc772185b87e6dbe66a40395f8a945a2
parentf3ef00b15226490ddb951cc774ca240a2f97fdee (diff)
downloadzsh-f70615d878b80f9303f7e04daa11cef9e133ac3b.tar.gz
zsh-f70615d878b80f9303f7e04daa11cef9e133ac3b.tar.xz
zsh-f70615d878b80f9303f7e04daa11cef9e133ac3b.zip
38981: _man: Followup to 37634: unbreak OpenBSD 'man 3p' and Linux $MANSECT.
The breakage was reported in 38516.
-rw-r--r--ChangeLog5
-rw-r--r--Completion/Unix/Command/_man16
2 files changed, 16 insertions, 5 deletions
diff --git a/ChangeLog b/ChangeLog
index 46256aee3..96522c602 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,8 @@
+2016-08-01  Daniel Shahaf  <d.s@daniel.shahaf.name>
+
+	* 38981: Completion/Unix/Command/_man: Followup to 37634:
+	unbreak OpenBSD 'man 3p' and Linux $MANSECT.
+
 2016-08-01  Peter Stephenson  <p.stephenson@samsung.com>
 
 	* Andy Spencer: 38982: Completion/Linux/Command/_cpupower: move
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index 0534db753..e892bb263 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -44,15 +44,21 @@ _man() {
   if [[ $OSTYPE = solaris* ]]; then
     sect=${${words[(R)-s*]#-s}:-$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
+    sect="${sect//:/|}"
+    sect="${sect//,/|}"
   elif (( CURRENT > 2 )); then
     sect=$words[2]
   fi
 
-  if [[ $sect = (<->*|1M|l|n) || $sect = \(*\|*\) ]]; then
-    dirs=( $^_manpath/(sman|man|cat)${~sect%%[^0-9]#}/ )
+  if [[ $sect = (<->*|1M|l|n) || $sect = *\|* ]]; then
+    () {
+      local -a sects=( ${(s.|.)sect} )
+      if [[ $sect != (l|n) ]]; then
+        sects=( ${sects%%[^0-9]#} )
+      fi
+      dirs=( $^_manpath/(sman|man|cat)${^sects}*/ )
+    }
+    if [[ $sect == *\|* ]]; then sect="($sect)"; fi
     awk="\$2 == \"$sect\" {print \$1}"
   else
     dirs=( $^_manpath/(sman|man|cat)*/ )