summaryrefslogtreecommitdiff
path: root/completions/ri
diff options
context:
space:
mode:
authorDavid Paleino <dapal@debian.org>2011-11-03 12:32:52 +0100
committerDavid Paleino <dapal@debian.org>2011-11-03 12:32:52 +0100
commit2c8171c38d87ddef31c92a76547d3fdf773a1337 (patch)
tree5e720d5a06ead72ed55454bf6647a712a761ed91 /completions/ri
parent9920a8faedf704420571d8072ccab27e9dac40ba (diff)
downloadbash-completion-2c8171c38d87ddef31c92a76547d3fdf773a1337.tar.gz
Imported Upstream version 1.90upstream/1.90
Diffstat (limited to 'completions/ri')
-rw-r--r--completions/ri31
1 files changed, 12 insertions, 19 deletions
diff --git a/completions/ri b/completions/ri
index be66d98f..70756325 100644
--- a/completions/ri
+++ b/completions/ri
@@ -1,6 +1,6 @@
-# ri completion for Ruby documentation by Ian Macdonald <ian@caliban.org>
+# ri completion for Ruby documentation -*- shell-script -*-
+# by Ian Macdonald <ian@caliban.org>
-have ri && {
ri_get_methods()
{
local regex
@@ -14,15 +14,15 @@ ri_get_methods()
regex=Class
fi
- COMPREPLY=( ${COMPREPLY[@]} \
+ COMPREPLY+=( \
"$( ri ${classes[@]} 2>/dev/null | ruby -ane \
'if /^'"$regex"' methods:/.../^------------------|^$/ and \
/^ / then print $_.split(/, |,$/).grep(/^[^\[]*$/).join("\n"); \
- end' | sort -u )" )
+ end' 2>/dev/null | sort -u )" )
else
# older versions of ri didn't distinguish between class/module and
# instance methods
- COMPREPLY=( ${COMPREPLY[@]} \
+ COMPREPLY+=( \
"$( ruby -W0 $ri_path ${classes[@]} | ruby -ane \
'if /^-/.../^-/ and ! /^-/ and ! /^ +(class|module): / then \
print $_.split(/, |,$| +/).grep(/^[^\[]*$/).join("\n"); \
@@ -34,11 +34,11 @@ ri_get_methods()
# needs at least Ruby 1.8.0 in order to use -W0
_ri()
{
- local cur class method prefix ri_path ri_version separator IFS
- local -a classes
+ local cur prev words cword
+ _init_completion || return
- COMPREPLY=()
- _get_comp_words_by_ref cur
+ local class method prefix ri_path ri_version separator IFS
+ local -a classes
ri_path=$(type -p ri)
# which version of ri are we using?
@@ -62,8 +62,8 @@ _ri()
if [ "$ri_version" = integrated ]; then
# integrated ri from Ruby 1.9
- classes=( $( ri -c | ruby -ne 'if /^\s*$/..$stdin.eof then \
- if /, [A-Z]+/ then print; end; end' ) )
+ classes=( $( ri -c 2>/dev/null | ruby -ne 'if /^\s*$/..$stdin.eof then \
+ if /, [A-Z]+/ then print; end; end' 2>/dev/null ) )
elif [ "$ri_version" = "ri 1.8a" ]; then
classes=( $( ruby -W0 $ri_path | \
ruby -ne 'if /^'"'"'ri'"'"' has/..$stdin.eof then \
@@ -83,14 +83,7 @@ _ri()
# we're completing on methods
method=$cur
ri_get_methods
-}
+} &&
complete -F _ri ri
-}
-# Local variables:
-# mode: shell-script
-# sh-basic-offset: 4
-# sh-indent-comment: t
-# indent-tabs-mode: nil
-# End:
# ex: ts=4 sw=4 et filetype=sh