Skip to content

Commit

Permalink
perl: Remove some duplicated code
Browse files Browse the repository at this point in the history
  • Loading branch information
scop committed May 13, 2016
1 parent 40e7b4e commit cf559ae
Showing 1 changed file with 7 additions and 22 deletions.
29 changes: 7 additions & 22 deletions completions/perl
Original file line number Diff line number Diff line change
@@ -1,26 +1,11 @@
# bash completion for perl -*- shell-script -*-

_perlmodules()
_perl_helper()
{
COMPREPLY=( $( compgen -P "$prefix" -W \
"$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl modules $cur )" \
"$( ${2:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl $1 $cur )" \
-- "$cur" ) )
__ltrim_colon_completions "$prefix$cur"
}

_perlfunctions()
{
COMPREPLY=( $( compgen -P "$prefix" -W \
"$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl functions $cur )" \
-- "$cur" ) )
}

_perldocs()
{
COMPREPLY=( $( compgen -P "$prefix" -W \
"$( ${1:-perl} ${BASH_SOURCE[0]%/*}/../helpers/perl perldocs $cur )" \
-- "$cur" ) )
__ltrim_colon_completions "$prefix$cur"
[[ $1 == functions ]] || __ltrim_colon_completions "$prefix$cur"
}

_perl()
Expand Down Expand Up @@ -58,7 +43,7 @@ _perl()
temp="${cur#-}"
prefix+="${cur%$temp}"
cur="$temp"
_perlmodules $1
_perl_helper modules $1
return 0
;;
-V)
Expand All @@ -78,7 +63,7 @@ _perl()
temp="${cur#:}"
prefix="$prefix${cur%$temp}"
cur="Devel::$temp"
_perlmodules $1
_perl_helper modules $1
fi
;;
esac
Expand Down Expand Up @@ -119,7 +104,7 @@ _perldoc()
return 0
;;
-f)
_perlfunctions $perl
_perl_helper functions $perl
return 0
;;
esac
Expand All @@ -129,7 +114,7 @@ _perldoc()
else
# return available modules (unless it is clearly a file)
if [[ "$cur" != @(*/|[.~])* ]]; then
_perldocs $perl
_perl_helper perldocs $perl
if [[ $cur == p* ]]; then
COMPREPLY+=( $( compgen -W \
'$( PERLDOC_PAGER=/bin/cat "$1" -u perl | \
Expand Down

0 comments on commit cf559ae

Please sign in to comment.