diff options
author | Jean Delvare <jdelvare@suse.de> | 2016-10-21 14:58:30 +0200 |
---|---|---|
committer | Jean Delvare <jdelvare@suse.de> | 2016-10-21 14:58:30 +0200 |
commit | 405c0483b5f9837d71e26e167e94e81991ee35a4 (patch) | |
tree | 077d9aac5651a900d4208aeb9458bd7ea0c85e88 /bash_completion | |
parent | 2d16d9230c6adbf56b0b23e51f6b5747208307a7 (diff) | |
download | quilt-405c0483b5f9837d71e26e167e94e81991ee35a4.tar.gz |
bash_completion: Drop duplicate functions
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.
Diffstat (limited to 'bash_completion')
-rw-r--r-- | bash_completion | 67 |
1 files changed, 1 insertions, 66 deletions
diff --git a/bash_completion b/bash_completion index be896d9..28934a1 100644 --- 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) |