[Bash-completion-commits] [SCM] bash-completion branch, dynamic-loading, updated. 1.3-471-gf6cd934

Ville Skyttä ville.skytta at iki.fi
Sun Oct 23 08:11:16 UTC 2011


The following commit has been merged in the dynamic-loading branch:
commit ff8e52c9605fa0a40d642d1ddb57ada11213ac3c
Author: Ville Skyttä <ville.skytta at iki.fi>
Date:   Sun Oct 23 11:02:46 2011 +0300

    _init_completion: Complete variable names.

diff --git a/bash_completion b/bash_completion
index 4bfa4de..716c3aa 100644
--- a/bash_completion
+++ b/bash_completion
@@ -605,11 +605,11 @@ _split_longopt()
     return 1
 }
 
-# Initialize completion and deal with redirections: do file completion where
-# appropriate, and adjust prev, words, and cword as if no redirections exist
-# so that completions do not need to deal with them.  Before calling this
-# function, make sure cur, prev, words, and cword are local, ditto split if
-# you use -s.
+# Initialize completion and deal with various general things: do file
+# and variable completion where appropriate, and adjust prev, words,
+# and cword as if no redirections exist so that completions do not
+# need to deal with them.  Before calling this function, make sure
+# cur, prev, words, and cword are local, ditto split if you use -s.
 #
 # Options:
 #     -n EXCLUDE  Passed to _get_comp_words_by_ref -n with redirection chars
@@ -644,6 +644,12 @@ _init_completion()
     local redir="@(?([0-9])<|?([0-9&])>?(>)|>&)"
     _get_comp_words_by_ref -n "$exclude<>&" cur prev words cword
 
+    # Complete variable names.
+    if [[ $cur == \$* ]]; then
+        COMPREPLY=( $( compgen -P '$' -v -- "${cur#\$}" ) )
+        return 1
+    fi
+
     # Complete on files if current is a redirect possibly followed by a
     # filename, e.g. ">foo", or previous is a "bare" redirect, e.g. ">".
     if [[ $cur == $redir* || $prev == $redir ]]; then

-- 
bash-completion



More information about the Bash-completion-commits mailing list