# bash completion for lintian(1) and lintian-info(1) -*- shell-script -*- proc _lintian_tags { local match search tags setglobal tags = $[ awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc] if [[ "$cur" == *, ]] { setglobal search = $(cur//,/ ) for item in [$search] { setglobal match = $[ command grep -nE "^Tag: $item$" \ /usr/share/lintian/checks/*.desc | cut -d: -f1] setglobal tags = $[ sed -e "s/\<$item\>//g" <<<$tags] } setglobal COMPREPLY = ''( $(compgen -W "$tags") ) } elif [[ "$cur" == *,* ]] { setglobal COMPREPLY = ''( $(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}") ) } else { setglobal COMPREPLY = ''( $(compgen -W "$tags" -- "$cur") ) } return 0 } proc _lintian_checks { local match search todisable checks setglobal checks = $[ awk '/^(Check-Script|Abbrev)/ { print $2 }' \ /usr/share/lintian/checks/*.desc] if [[ "$cur" == *, ]] { setglobal search = $(cur//,/ ) for item in [$search] { setglobal match = $[ command grep -nE "^(Check-Script|Abbrev): $item$" \ /usr/share/lintian/checks/*.desc | cut -d: -f1] setglobal todisable = $[ awk '/^(Check-Script|Abbrev)/ { print $2 }' $match] for name in [$todisable] { setglobal checks = $[ sed -e "s/\<$name\>//g" <<<$checks] } } setglobal COMPREPLY = ''( $(compgen -W "$checks") ) } elif [[ "$cur" == *,* ]] { setglobal COMPREPLY = ''( $(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}") ) } else { setglobal COMPREPLY = ''( $(compgen -W "$checks" -- "$cur") ) } return 0 } proc _lintian_infos { local match search infos setglobal infos = $[ awk '/^Collector/ { print $2 }' \ /usr/share/lintian/collection/*.desc] if [[ "$cur" == *, ]] { setglobal search = $(cur//,/ ) for item in [$search] { setglobal match = $[ command grep -nE "^Collector: $item$" \ /usr/share/lintian/collection/*.desc | cut -d: -f1] setglobal infos = $[ sed -e "s/\<$item\>//g" <<<$infos] } setglobal COMPREPLY = ''( $(compgen -W "$infos") ) } elif [[ "$cur" == *,* ]] { setglobal COMPREPLY = ''( $(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}") ) } else { setglobal COMPREPLY = ''( $(compgen -W "$infos" -- "$cur") ) } return 0 } proc _lintian_arches { return 0 } proc _lintian { local cur prev words cword _init_completion || return local action lint_actions general_opts behaviour_opts \ configuration_opts selection_opts setglobal lint_actions = '"--setup-lab --remove-lab --check --check-part --tags --tags-from-file --ftp-master-rejects --dont-check-part --unpack --remove'" setglobal general_opts = '"--help --version --print-version --verbose --debug --quiet'" setglobal behaviour_opts = '"--info --display-info --display-experimental --pedantic --display-level --suppress-tags --suppress-tags-from-file --no-override --show-overrides --color --unpack-info --md5sums --checksums --allow-root --fail-on-warnings --keep-lab'" setglobal configuration_opts = '"--cfg --lab --archivedir --dist --area --section --arch --root'" setglobal selection_opts = '"--all --binary --source --udeb --packages-file'" if [[ "$prev" == -* ]] { match $prev { with -C|--check-part|-X|--dont-check-part _lintian_checks with -T|--tags|--suppress-tags _lintian_tags with --tags-from-file|--suppress-tags-from-file|--cfg|-p|\ --packages-file _filedir with --lab|--archivedir|--dist|--root _filedir -d with --color setglobal COMPREPLY = ''($(compgen -W "never always auto html" -- "$cur")) with -U|--unpack-info _lintian_infos with --area|--section setglobal COMPREPLY = ''($(compgen -W "main contrib non-free" -- "$cur")) with --arch } } match $cur { with --* setglobal COMPREPLY = ''($(compgen -W "$lint_actions $general_opts $behaviour_opts $configuration_opts" -- "$cur")) with *, # If we're here, the user is trying to complete on # --action tag,tag, # Only few actions permit that, re-complete them now. match $prev { with -C|--check-part|-X|--dont-check-part _lintian_checks with -T|--tags|--suppress-tags _lintian_tags with -U|--unpack-info _lintian_infos } with * _filedir '@(?(u)deb|changes|dsc)' } return 0 } && complete -F _lintian lintian proc _lintian_info { local cur prev words cword _init_completion || return match $prev { with -t|--tags _lintian_tags return 0 } match $cur { with --* setglobal COMPREPLY = ''($(compgen -W "--annotate --help --tags" -- "$cur")) with * _filedir } return 0 } && complete -F _lintian_info lintian-info # ex: ts=4 sw=4 et filetype=sh