1# /usr/share/bash-completion/completions/debdiff 2# Bash command completion for ‘debdiff(1)’. 3# Documentation: ‘bash(1)’, section “Programmable Completion”. 4 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. 8 9_have debdiff && 10_debdiff () { 11 local cur prev words cword 12 _init_completion || return 13 14 local i 15 local command_name=debdiff 16 local options=( 17 -h --help -v --version 18 -q --quiet 19 -d --dirs --nodirs 20 -w --ignore-space 21 --diffstat --no-diffstat 22 --auto-ver-sort --no-auto-ver-sort 23 --unpack-tarballs --no-unpack-tarballs 24 --control --nocontrol --controlfiles 25 --wdiff-source-control --no-wdiff-source-control --wp --wl --wt 26 --show-moved --noshow-moved --renamed 27 --debs-dir 28 --from 29 --move --move-regex 30 --exclude 31 ) 32 33 local file_list_mode=normal 34 local -i move_from=-1 35 local -i move_to=-1 36 37 unset COMPREPLY 38 39 case "$prev" in 40 "$command_name") 41 options+=( --noconf --no-conf ) 42 ;; 43 44 --debs-dir) 45 COMPREPLY=( $( compgen -A directory -- "$cur" ) ) 46 ;; 47 48 esac 49 50 if [[ -v COMPREPLY ]] ; then 51 return 0 52 fi 53 54 for (( i=1; i<${#words[@]}; i++ )); do 55 if [[ $file_list_mode == @(deb|dsc|changes) ]]; then 56 if (( i == ${#words[@]}-1 )); then 57 break 58 else 59 COMPREPLY=() 60 return 0 61 fi 62 fi 63 if (( ${move_from} == -1 && ${move_to} == -1 )); then 64 file_list_mode=normal 65 elif (( ${move_from} >= 0 && ${move_to} == -1 )); then 66 file_list_mode=from 67 elif (( ${move_from} >= 0 && ${move_to} >= 0 && ${move_to} < ${move_from} )); then 68 file_list_mode=to 69 else 70 COMPREPLY=() 71 return 0 72 fi 73 if [[ $file_list_mode == normal && ${words[i]} == --from ]]; then 74 move_from=0 75 file_list_mode=from 76 elif [[ $file_list_mode == normal && ${words[i]} == *.deb ]]; then 77 file_list_mode=deb 78 elif [[ $file_list_mode == normal && ${words[i]} == *.udeb ]]; then 79 file_list_mode=deb 80 elif [[ $file_list_mode == normal && ${words[i]} == *.dsc ]]; then 81 file_list_mode=dsc 82 elif [[ $file_list_mode == normal && ${words[i]} == *.changes ]]; then 83 file_list_mode=changes 84 elif [[ $file_list_mode == from && ${words[i]} == *.deb ]]; then 85 (( ++move_from )) 86 elif [[ $file_list_mode == from && ${words[i]} == *.udeb ]]; then 87 (( ++move_from )) 88 elif [[ $file_list_mode == from && ${words[i]} == --to ]]; then 89 move_to=0 90 file_list_mode=to 91 elif [[ $file_list_mode = to && ${words[i]} == *.deb ]]; then 92 (( ++move_to )) 93 elif [[ $file_list_mode = to && ${words[i]} == *.udeb ]]; then 94 (( ++move_to )) 95 fi 96 done 97 98 case $file_list_mode in 99 normal) 100 if [[ $prev == --debs-dir ]]; then 101 COMPREPLY=( $( compgen -G "${cur}*" ) ) 102 compopt -o dirnames 103 elif [[ $cur == -* ]]; then 104 COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) 105 else 106 COMPREPLY=( $( compgen -G "${cur}*.@(deb|udeb|dsc|changes)" ) ) 107 compopt -o filenames 108 compopt -o plusdirs 109 fi 110 ;; 111 deb|from|to) 112 COMPREPLY=( $( compgen -G "${cur}*.deb" "${cur}*.udeb" ) ) 113 if (( $move_from > 0 && $move_to < 0 )) ; then 114 COMPREPLY+=( $( compgen -W "--to" -- "$cur" ) ) 115 fi 116 compopt -o filenames 117 compopt -o plusdirs 118 ;; 119 dsc) 120 COMPREPLY=( $( compgen -G "${cur}*.dsc" ) ) 121 compopt -o filenames 122 compopt -o plusdirs 123 ;; 124 changes) 125 COMPREPLY=( $( compgen -G "${cur}*.changes" ) ) 126 compopt -o filenames 127 compopt -o plusdirs 128 ;; 129 *) 130 COMPREPLY=( $( compgen -W "${options[*]}" -- "$cur" ) ) 131 ;; 132 esac 133 134 return 0 135 136} && 137complete -F _debdiff debdiff 138 139 140# Copyright © 2016–2017 Ben Finney <ben+debian@benfinney.id.au> 141# Copyright © 2015 Nicholas Bamber <nicholas@periapt.co.uk> 142# 143# This is free software: you may copy, modify, and/or distribute this work 144# under the terms of the GNU General Public License as published by the 145# Free Software Foundation; version 2 of that license or any later version. 146# No warranty expressed or implied. See the file ‘LICENSE.GPL-2’ for details. 147 148# Local variables: 149# coding: utf-8 150# mode: shell-script 151# indent-tabs-mode: nil 152# End: 153# vim: fileencoding=utf-8 filetype=sh expandtab shiftwidth=4 : 154