summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVille Skyttä <ville.skytta@iki.fi>2011-10-26 19:56:22 +0300
committerVille Skyttä <ville.skytta@iki.fi>2011-10-26 19:56:22 +0300
commit802a72fd8f39c37c09458bdb224fd3c07f9c15a4 (patch)
tree3a14326b9af22c06cdf2d9b61a11e41ac21758c4
parent5811d47f0ee8642fd2dc474ea82bd00391b9735b (diff)
downloadbash-completion-802a72fd8f39c37c09458bdb224fd3c07f9c15a4.tar.gz
_command_offset: Drop unused variables, define some others only when needed.
-rw-r--r--bash_completion13
1 files changed, 5 insertions, 8 deletions
diff --git a/bash_completion b/bash_completion
index 1656a714..233616f1 100644
--- a/bash_completion
+++ b/bash_completion
@@ -1559,17 +1559,13 @@ _command()
#
_command_offset()
{
- local cur func cline cspec noglob cmd compcmd i char_offset word_offset \
- _COMMAND_FUNC _COMMAND_FUNC_ARGS
-
- word_offset=$1
-
# rewrite current completion context before invoking
# actual command completion
# find new first word position, then
# rewrite COMP_LINE and adjust COMP_POINT
- local first_word=${COMP_WORDS[$word_offset]}
+ local word_offset=$1
+ local first_word=${COMP_WORDS[$word_offset]} char_offset i
for (( i=0; i <= ${#COMP_LINE}; i++ )); do
if [[ "${COMP_LINE:$i:${#first_word}}" == "$first_word" ]]; then
char_offset=$i
@@ -1589,6 +1585,7 @@ _command_offset()
COMP_CWORD=$(( $COMP_CWORD - $word_offset ))
COMPREPLY=()
+ local cur
_get_comp_words_by_ref cur
if [[ $COMP_CWORD -eq 0 ]]; then
@@ -1596,7 +1593,7 @@ _command_offset()
compopt -o filenames
COMPREPLY=( $( compgen -d -c -- "$cur" ) )
else
- cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}
+ local cspec cmd=${COMP_WORDS[0]} compcmd=${COMP_WORDS[0]}
# Do we have full path completion for $cmd?
if ! cspec=$( complete -p $cmd 2>/dev/null ) && [[ $cmd == */* ]]; then
# Nope, what about the basename?
@@ -1608,7 +1605,7 @@ _command_offset()
# complete -F <function>
# get function name
- func=${cspec#*-F }
+ local func=${cspec#*-F }
func=${func%% *}
if [[ ${#COMP_WORDS[@]} -ge 2 ]]; then