[Bash-completion-commits] [SCM] bash-completion branch, master, updated. cbf7e1f96387bdccdc965e5ed49de58b7dfceeef

Freddy Vulto fvulto at gmail.com
Wed Dec 9 21:17:16 UTC 2009


The following commit has been merged in the master branch:
commit 6fe53ef0e65554d51e94fb7c21db2d510d8390d8
Author: Freddy Vulto <fvulto at gmail.com>
Date:   Wed Dec 9 22:13:56 2009 +0100

    Fixed completing perl modules containing colons
    The solution for bash-4 is to remove the colon from COMP_WORDBREAKS:
    
       COMP_WORDBREAKS=${COMP_WORDBREAKS//:}
    
    The workaround for bash-3, or bash-4 with a colon in COMP_WORDBREAKS,
    is to call:
    
      __ltrim_colon_completions "$cur"
    
    after completions have been put in COMPREPLY.
    
    See also: E13) Why does filename completion misbehave if a colon appears
    in the filename? - Bash FAQ, http://tiswww.case.edu/php/chet/bash/FAQ

diff --git a/contrib/perl b/contrib/perl
index 1e84803..4041bcb 100644
--- a/contrib/perl
+++ b/contrib/perl
@@ -4,7 +4,8 @@ have perl &&
 {
 _perlmodules()
 {
-    COMPREPLY=( $( compgen -P "$prefix" -W "$( perl -e 'sub mods { my ($base,$dir)=@_; return if  $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}\\\\:\\\\:],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' )" -- "$cur" ) )
+    COMPREPLY=( $( compgen -P "$prefix" -W "$( perl -e 'sub mods { my ($base,$dir)=@_; return if  $base !~ /^\Q$ENV{cur}/; chdir($dir) or return; for (glob(q[*.pm])) {s/\.pm$//; print qq[$base$_\n]}; mods(/^(?:[.\d]+|$Config{archname}-$Config{osname}|auto)$/ ? undef : qq[${base}${_}::],qq[$dir/$_]) for grep {-d} glob(q[*]); } mods(undef,$_) for @INC;' )" -- "$cur" ) )
+    __ltrim_colon_completions "$1"
 }
 
 _perl()
@@ -35,7 +36,7 @@ _perl()
             return 0
             ;;
         -m|-M)
-            _perlmodules
+            _perlmodules "$cur"
             return 0
             ;;
     esac
@@ -107,7 +108,7 @@ _perldoc()
     else
         # return available modules (unless it is clearly a file)
         if [[ "$cur" != */* ]]; then
-            _perlmodules
+            _perlmodules "$cur"
             COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W \
                 '$( PAGER=/bin/cat man perl |  \
                 sed -ne "/perl.*Perl overview/,/perlwin32/p" | \
diff --git a/test/lib/completions/perldoc.exp b/test/lib/completions/perldoc.exp
index 01eab99..d5221a6 100644
--- a/test/lib/completions/perldoc.exp
+++ b/test/lib/completions/perldoc.exp
@@ -17,4 +17,22 @@ assert_complete_any "perldoc -"
 sync_after_int
 
 
+set test "perldoc should complete word containing colons"
+set cmd "perldoc HTML::"
+send "$cmd\t"
+expect {
+    # Assuming the module `HTML::Parser' is always installed
+    -re "\\sParser\\s" { pass "$test" }
+    # Assuming there's no perl module named `fixtures', but only our directory
+    # `test/fixtures' which is presented falsely.
+    -re "\\sfixtures/\\s" { fail "$test" }
+    -re "perldoc HTML::HTML::" { fail "$test" }
+    -re /@ { unresolved "$test" }
+    default { unresolved "$test" }
+}; # expect
+
+
+sync_after_int
+
+
 teardown

-- 
bash-completion



More information about the Bash-completion-commits mailing list