Completing long options of the grep command is not a fundamental
feature. I can't remember ever needing it. The most useful grep
options are short ones by design. Additionally, our internal
implementation of _longopt is broken as far as I can tell.

So drop our implementations of _expand, _filedir and _longopt, and
only call _longopt if it is already available from bash-completion.
---
 bash_completion |   67 --------------------------------------------------------
 1 file changed, 1 insertion(+), 66 deletions(-)

--- a/bash_completion
+++ b/bash_completion
@@ -13,71 +13,6 @@
 
 if type quilt &> /dev/null ; then
 
-if ! type _expand &> /dev/null ; then
-    # This function expands tildes in pathnames
-    #
-    _expand()
-    {
-       [ "$cur" != "${cur%\\}" ] && cur="$cur"'\'
-
-       # expand ~username type directory specifications
-       if [[ "$cur" == \~*/* ]]; then
-           eval cur=$cur
-       elif [[ "$cur" == \~* ]]; then
-           cur=${cur#\~}
-           COMPREPLY=( $( compgen -P '~' -u $cur ) )
-           return ${#COMPREPLY[@]}
-       fi
-    }
-fi
-
-if ! type _filedir &> /dev/null ; then
-    # This function performs file and directory completion. It's better than
-    # simply using 'compgen -f', because it honours spaces in filenames
-    #
-    _filedir()
-    {
-       local IFS=$'\t\n'
-
-       _expand || return 0
-
-       if [ "$1" = -d ]; then
-           COMPREPLY=( ${COMPREPLY[@]} $( compgen -d -- $cur ) )
-           return 0
-       fi
-       COMPREPLY=( ${COMPREPLY[@]} $( eval compgen -f -- \"$cur\" ) )
-    }
-fi
-
-if ! type _longopt &> /dev/null ; then
-    _longopt()
-    {
-       local cur opt
-
-       cur=${COMP_WORDS[COMP_CWORD]}
-
-       if [[ "$cur" == "--*=*" ]]; then
-           opt=${cur%%=*}
-           # cut backlash that gets inserted before '=' sign
-           opt=${opt%\\*}
-           cur=${cur#*=}
-           _filedir
-           COMPREPLY=( $( compgen -P "$opt=" -W '${COMPREPLY[@]}' -- $cur))
-           return 0
-       fi
-
-       if [[ "$cur" == "-*" ]]; then
-           COMPREPLY=( $( $1 --help 2>&1 | sed  -e '/--/!d' \
-                           -e 's/.*\(--[-A-Za-z0-9]\+=\?\).*/\1/' | \
-                          grep "^$cur" | sort -u ) )
-       elif [[ "$1" == "@(mk|rm)dir" ]]; then
-           _filedir -d
-       else
-           _filedir
-       fi
-    }
-fi
-
 # Complete on files (by default) or directories (with -d)
 #
 _quilt_comfile()
@@ -203,7 +138,7 @@ _quilt_completion()
           esac
           ;;
        grep)
-          _longopt grep
+          type _longopt &> /dev/null && _longopt grep
           COMPREPLY=( "${COMPREPLY[@]}" $( compgen -W "-h" -- $cur ) )
           ;;
        header)



_______________________________________________
Quilt-dev mailing list
[email protected]
https://lists.nongnu.org/mailman/listinfo/quilt-dev

Reply via email to