summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBart Schaefer <barts@users.sourceforge.net>2008-03-03 01:29:17 +0000
committerBart Schaefer <barts@users.sourceforge.net>2008-03-03 01:29:17 +0000
commit25848c5aa728935f12cd97ed92412f319048fb87 (patch)
tree8248a1af2e70f2e5a06794ae7ca9d5eab52bd0ed
parente5a6543e6daeb8cb8e2cd37856814e24ce4407df (diff)
downloadzsh-25848c5aa728935f12cd97ed92412f319048fb87.tar.gz
zsh-25848c5aa728935f12cd97ed92412f319048fb87.zip
24653, 24659: Completion/Unix/Type/_path_commands: use a helper function
to call "whatis" portably, and use compadd -O to pre-filter matches before reading $_command_descriptions.
-rw-r--r--ChangeLog6
-rw-r--r--Completion/Unix/Type/_path_commands18
2 files changed, 21 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 477084ee8..c87accf0a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+2008-03-02 Barton E. Schaefer <schaefer@zsh.org>
+
+ * 24653, 24659: Completion/Unix/Type/_path_commands: use a
+ helper function to call "whatis" portably, and use compadd -O
+ to pre-filter matches before reading $_command_descriptions.
+
2008-03-02 Peter Stephenson <p.w.stephenson@ntlworld.com>
* 24656: Src/builtin.c: fix cd overeagerness to find integers
diff --git a/Completion/Unix/Type/_path_commands b/Completion/Unix/Type/_path_commands
index 0a4e3d512..340a013c3 100644
--- a/Completion/Unix/Type/_path_commands
+++ b/Completion/Unix/Type/_path_commands
@@ -23,6 +23,17 @@ done
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]"
+ ;;
+ (*) whatis "$@";;
+ esac
+}
+
_path_commands() {
local need_desc expl ret=1
@@ -38,7 +49,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 whatis -s 1 -r .\\\*\; whatis -s 6 -r .\\\* 2> /dev/null)}"; do
+ for line in "${(f)$(_call_program command-descriptions _call_whatis -s 1 -r .\\\*\; _call_whatis -s 6 -r .\\\* 2>/dev/null)}"; do
[[ -n ${line:#(#b)([^ ]#) #\([^ ]#\)( #\[[^ ]#\]|)[ -]#(*)} ]] && continue;
[[ -z $match[1] || -z $match[3] || -z ${${match[1]}:#*:*} ]] && continue;
_command_descriptions[$match[1]]=$match[3]
@@ -50,9 +61,10 @@ if zstyle -t ":completion:${curcontext}:" extra-verbose; then
fi
if [[ -n $need_desc ]]; then
- typeset -a dcmds descs cmds
+ typeset -a dcmds descs cmds matches
local desc cmd sep
- for cmd in ${(k)commands}; do
+ compadd "$@" -O matches -k commands
+ for cmd in $matches; do
desc=$_command_descriptions[$cmd]
if [[ -z $desc ]]; then
cmds+=$cmd