summaryrefslogtreecommitdiff
path: root/Completion/Unix/Command
diff options
context:
space:
mode:
authorDaniel Shahaf <d.s@daniel.shahaf.name>2016-08-04 15:54:24 +0000
committerDaniel Shahaf <d.s@daniel.shahaf.name>2016-08-05 12:37:29 +0000
commit71f1653020563696b162753539137e355f585c4d (patch)
treea26ac936aa5ee9df8bca9eb465269b1776decd4f /Completion/Unix/Command
parenta5a9fc7a5fc50db278f7d17eb8d2ae78f3edc768 (diff)
downloadzsh-71f1653020563696b162753539137e355f585c4d.tar.gz
zsh-71f1653020563696b162753539137e355f585c4d.zip
38994: _man: Fix two bugs when completing manpage filenames in separate-sections mode.
- No longer glob all files (the (-g)-less _path_files was virtually always called, by at least one of the multiple calls to _man_pages). - Actually separate sections (by propagating $expl).
Diffstat (limited to 'Completion/Unix/Command')
-rw-r--r--Completion/Unix/Command/_man17
1 files changed, 14 insertions, 3 deletions
diff --git a/Completion/Unix/Command/_man b/Completion/Unix/Command/_man
index ef17ad8ee..ffe53be5e 100644
--- a/Completion/Unix/Command/_man
+++ b/Completion/Unix/Command/_man
@@ -87,6 +87,13 @@ _man() {
done
(( ret )) || return 0
done
+ ## To fall back to other sections' manpages when completing filenames, like
+ ## the 'else' codepath does:
+ #
+ # if (( ret )) && [[ $PREFIX$SUFFIX == */* ]]; then
+ # sect_dirname=
+ # _wanted manuals expl 'manual page' _man_pages && return
+ # fi
return 1
else
@@ -105,9 +112,13 @@ _man_pages() {
# Easy way to test for versions of man that allow file names.
# This can't be a normal man page reference.
# Try to complete by glob first.
- _path_files -g "*$suf" && return
- _path_files
- return
+ if [[ -n $sect_dirname ]]; then
+ _path_files -g "*.*$sect_dirname*(|.gz|.bz2|.Z|.lzma)" "$expl[@]"
+ else
+ _path_files -g "*$suf" "$expl[@]" && return
+ _path_files "$expl[@]"
+ fi
+ return $?
fi
zparseopts -E M+:=matcher