Package: bash-completion
Version: 1:1.3-1
Severity: normal
Tags: patch
When trying to complete the name of a script after -d, I get no
completions. E.g.:
perl -d tab
The problem is that there are two cases:
1. We are at -d*, so we shift that into $prev, put the rest of it in
$cur, and then look for :* in $cur.
2. We are at -d , and $prev remains -d, but we still try to look
for :* in $cur.
So case (2) is wrong; we will complete -d :DProf, which doesn't make
any sense (and isn't accepted by perl). And if you have no colon, you
get no completions at all.
There is a similar problem for -V: and -M (which will complete -M
module, which perl complains about).
The attached patch fixes it for me. It looks for options in
$prev only if we did the $cur/$prev shift, and otherwise completes as
normal.
-- System Information:
Debian Release: wheezy/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.37-1-amd64 (SMP w/8 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Versions of packages bash-completion depends on:
ii bash 4.1-3 The GNU Bourne Again SHell
bash-completion recommends no packages.
bash-completion suggests no packages.
-- no debconf information
diff --git a/completions/perl b/completions/perl
index 843e249..fca70fd 100644
--- a/completions/perl
+++ b/completions/perl
@@ -30,49 +30,48 @@ _perl()
optPrefix=-P$prev
optSuffix=-S/
prefix=$prev
-fi
-case $prev in
--D|-e|-E|-i|-F|-l)
-return 0
-;;
--I|-x)
-local IFS=$'\n'
-_compopt_o_filenames
-COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- $cur ) )
-return 0
-;;
--m|-M)
-temp=${cur#-}
-prefix=$prefix${cur%$temp}
-cur=$temp
-_perlmodules $1
-return 0
-;;
--V)
-if [[ $cur == :* ]]; then
-temp=${cur##+(:)}
-prefix=$prefix${cur%$temp}
-local IFS=$'\n'
-COMPREPLY=( $( compgen -P $prefix -W \
-'$( $1 -MConfig -e print join \\\n\,
-keys %Config::Config 2/dev/null )' -- $temp ) )
-__ltrim_colon_completions $prefix$temp
-fi
-return 0
-;;
--d|-dt)
-if [[ $cur == :* ]]; then
-temp=${cur#:}
-prefix=$prefix${cur%$temp}
-cur=Devel::$temp
-_perlmodules $1
-fi
-return 0
-;;
-esac
+case $prev in
+-D|-e|-E|-i|-F|-l)
+return 0
+;;
+-I|-x)
+local IFS=$'\n'
+_compopt_o_filenames
+COMPREPLY=( $( compgen -d $optPrefix $optSuffix -- $cur ) )
+return 0
+;;
+-m|-M)
+temp=${cur#-}
+prefix=$prefix${cur%$temp}
+cur=$temp
+_perlmodules $1
+return 0
+;;
+-V)
+if [[ $cur == :* ]]; then
+temp=${cur##+(:)}
+prefix=$prefix${cur%$temp}
+local IFS=$'\n'
+COMPREPLY=( $( compgen -P $prefix -W \
+'$( $1 -MConfig -e print join \\\n\,
+keys %Config::Config 2/dev/null )' -- $temp ) )
+__ltrim_colon_completions $prefix$temp
+fi
+return 0
+;;
+-d|-dt)
+if [[ $cur == :* ]]; then
+temp=${cur#:}
+prefix=$prefix${cur%$temp}
+cur=Devel::$temp
+_perlmodules $1
+fi
+return 0
+;;
+esac
-if [[ $cur == -* ]]; then
+elif [[ $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