The patch proposed in the initial bug report has the problem that
since -* is stripped off of $cur and placed in $prev in the opening
lines of the _perl function, the test will always be true.

I have attached my approach to the same problem, with the addition of
completing -I and -x arguments (which may easily be ignored if
considered unnecessary).

Cheers,
Kevin
--- bash_completion.old 2008-02-07 01:28:45.000000000 -0700
+++ bash_completion     2008-02-07 01:40:41.000000000 -0700
@@ -5188,6 +5188,10 @@
 
     # only handle module completion for now
     case "$prev" in
+       -I|-x)
+           COMPREPLY=( $( compgen -d -P "$prev" -- "$cur" ) )
+           return 0
+           ;;
        -m|-M)
            _perlmodules
            return 0
@@ -5195,7 +5199,7 @@
     esac
 
     # handle case where first parameter is not a dash option
-    if [ $COMP_CWORD -eq 1 ] && [[ "$cur" != -* ]]; then
+    if [[ "${COMP_WORDS[COMP_CWORD]}" != -* ]]; then
        _filedir
        return 0
     fi

Reply via email to