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
This commit is contained in:
parent
098dc9c1b8
commit
6fe53ef0e6
@ -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" | \
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user