quilt-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Quilt-dev] [patch 5/5] bash_completion: Drop duplicate functions


From: Jean Delvare
Subject: [Quilt-dev] [patch 5/5] bash_completion: Drop duplicate functions
Date: Sat, 22 Feb 2014 22:35:23 +0100
User-agent: quilt/0.61-1

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 address@hidden
-       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=( address@hidden $( compgen -d -- $cur ) )
-           return 0
-       fi
-       COMPREPLY=( address@hidden $( 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 'address@hidden' -- $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=( "address@hidden" $( compgen -W "-h" -- $cur ) )
           ;;
        header)





reply via email to

[Prev in Thread] Current Thread [Next in Thread]