summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGuillaume Rousse <guillomovitch@zarb.org>2009-02-10 23:39:10 +0100
committerGuillaume Rousse <guillomovitch@zarb.org>2009-02-10 23:39:10 +0100
commit9e08218fb933f4fea858da5928ccc7978603250a (patch)
treef181da2e70f4c614124805d643037be48bec50bc
parent47d0c5be2c1a30de898351a58d124343feb0a36f (diff)
downloadbash-completion-9e08218fb933f4fea858da5928ccc7978603250a.tar.gz
make perl completion a bit more consistant with other, by first dealing
with options, then with main arguments
-rw-r--r--bash_completion34
1 files changed, 12 insertions, 22 deletions
diff --git a/bash_completion b/bash_completion
index 76558961..0a5d75fe 100644
--- a/bash_completion
+++ b/bash_completion
@@ -5361,16 +5361,12 @@ _perl()
;;
esac
- # handle case where first parameter is not a dash option
- if [[ "`_get_cword`" != -* ]]; then
+ if [[ "$cur" == -* ]]; then
+ COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d \
+ -D -p -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
+ else
_filedir
- return 0
fi
-
- # complete using basic options
- COMPREPLY=( $( compgen -W '-C -s -T -u -U -W -X -h -v -V -c -w -d -D -p \
- -n -a -F -l -0 -I -m -M -P -S -x -i -e ' -- $cur ) )
- return 0
}
complete -F _perl $nospace $filenames perl
@@ -5427,21 +5423,15 @@ _perldoc()
;;
esac
- case $cur in
- -*)
+ if [[ "$cur" == -* ]]; then
COMPREPLY=( $( compgen -W '-h -v -t -u -m -l -F -X -f -q' -- $cur ))
- return 0
- ;;
- */*)
- return 0
- ;;
- *)
- _perlmodules
- COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=/bin/cat man perl | sed -ne "/perl.*Perl overview/,/perlwin32/p" | awk "\$NF=2 { print \$1}" | grep perl )' -- $cur ) )
-
- return 0
- ;;
- esac
+ else
+ # return available modules (unless it is clearly a file)
+ if [[ "$cur" != */* ]]; then
+ _perlmodules
+ COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W '$( PAGER=/bin/cat man perl | sed -ne "/perl.*Perl overview/,/perlwin32/p" | awk "\$NF=2 { print \$1}" | grep perl )' -- $cur ) )
+ fi
+ fi
}
complete -F _perldoc $default perldoc
}