Use correct idiom to specify current word for matching.
[dput.git] / bash-completion / dput.bash
blobf0e019343ce2792501d687e5b5efdc3b14c5dd1f
1 # bash-completion/dput.bash
2 # Programmable Bash command completion for ‘dput’ command.
3 # See the Bash manual “Programmable Completion” section.
5 # This is free software, and you are welcome to redistribute it under
6 # certain conditions; see the end of this file for copyright
7 # information, grant of license, and disclaimer of warranty.
9 _have dput &&
10 _dput () {
11 COMPREPLY=()
13 local cur="${COMP_WORDS[COMP_CWORD]}"
14 local prev="${COMP_WORDS[COMP_CWORD-1]}"
16 local options="
17 -c --config -d --debug -D --dinstall -f --force -h --help
18 -H --host-list -l --lintian -o --check-only -p --print
19 -P --passive -s --simulate -u --unchecked -e --delayed
20 -v --version -V --check-version
23 local config_files=(
24 "$HOME/.dput.cf"
25 "/etc/dput.cf"
27 local hosts=$( {
28 grep --no-filename "^\[.*\]" "${config_files[@]}" \
29 2> /dev/null \
30 | tr --delete [] || /bin/true
31 } | grep --invert-match '^DEFAULT$' | sort --unique )
33 case "$prev" in
34 -e|--delayed)
35 local delayed_options='0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15'
36 COMPREPLY=( $( compgen -W "$delayed_options" -- "$cur" ) )
38 -c|--config)
39 COMPREPLY=( $( compgen -o filenames -G "${cur}*" ) )
42 COMPREPLY=( $(
43 compgen -G "${cur}*.changes"
44 compgen -G "${cur}*.dsc"
45 compgen -W "$hosts" -- "$cur"
46 compgen -W "$options" -- "$cur"
47 ) )
49 esac
51 return 0
53 } && complete -F _dput -o filenames -o plusdirs dput
56 # Copyright © 2015–2016 Ben Finney <bignose@debian.org>
57 # Copyright © 2002 Roland Mas <lolando@debian.org>
59 # This is free software: you may copy, modify, and/or distribute this work
60 # under the terms of the GNU General Public License as published by the
61 # Free Software Foundation; version 3 of that license or any later version.
62 # No warranty expressed or implied. See the file ‘LICENSE.GPL-3’ for details.
64 # Local variables:
65 # coding: utf-8
66 # mode: sh
67 # End:
68 # vim: fileencoding=utf-8 filetype=sh :