2011-11-01 22:14:45 +02:00
|
|
|
# bash completion for lintian(1) and lintian-info(1) -*- shell-script -*-
|
2010-05-24 18:23:24 +02:00
|
|
|
|
2011-04-04 22:14:39 +03:00
|
|
|
_lintian_tags()
|
|
|
|
{
|
2010-05-24 18:23:24 +02:00
|
|
|
local match search tags
|
|
|
|
|
2014-01-06 17:38:35 +02:00
|
|
|
tags=$( awk '/^Tag/ { print $2 }' /usr/share/lintian/checks/*.desc )
|
2010-05-24 18:23:24 +02:00
|
|
|
if [[ "$cur" == *, ]]; then
|
|
|
|
search=${cur//,/ }
|
|
|
|
for item in $search; do
|
2014-01-06 17:45:48 +02:00
|
|
|
match=$( command grep -nE "^Tag: $item$" \
|
|
|
|
/usr/share/lintian/checks/*.desc | cut -d: -f1 )
|
2011-11-26 16:08:29 +02:00
|
|
|
tags=$( sed -e "s/\<$item\>//g" <<<$tags )
|
2010-05-24 18:23:24 +02:00
|
|
|
done
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -W "$tags") )
|
2010-05-24 18:23:24 +02:00
|
|
|
elif [[ "$cur" == *,* ]]; then
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$tags" -- "${cur##*,}") )
|
2010-05-24 18:23:24 +02:00
|
|
|
else
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -W "$tags" -- "$cur") )
|
2010-05-24 18:23:24 +02:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-04-04 22:14:39 +03:00
|
|
|
_lintian_checks()
|
|
|
|
{
|
2010-05-24 18:23:24 +02:00
|
|
|
local match search todisable checks
|
|
|
|
|
2014-01-06 17:38:35 +02:00
|
|
|
checks=$( awk '/^(Check-Script|Abbrev)/ { print $2 }' \
|
|
|
|
/usr/share/lintian/checks/*.desc )
|
2010-05-24 18:23:24 +02:00
|
|
|
if [[ "$cur" == *, ]]; then
|
|
|
|
search=${cur//,/ }
|
|
|
|
for item in $search; do
|
2014-01-06 17:45:48 +02:00
|
|
|
match=$( command grep -nE "^(Check-Script|Abbrev): $item$" \
|
|
|
|
/usr/share/lintian/checks/*.desc | cut -d: -f1 )
|
2014-01-06 17:38:35 +02:00
|
|
|
todisable=$( awk '/^(Check-Script|Abbrev)/ { print $2 }' $match )
|
2010-05-24 18:23:24 +02:00
|
|
|
for name in $todisable; do
|
2011-11-26 16:08:29 +02:00
|
|
|
checks=$( sed -e "s/\<$name\>//g" <<<$checks )
|
2010-05-24 18:23:24 +02:00
|
|
|
done
|
|
|
|
done
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -W "$checks") )
|
2010-05-24 18:23:24 +02:00
|
|
|
elif [[ "$cur" == *,* ]]; then
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$checks" -- "${cur##*,}") )
|
2010-05-24 18:23:24 +02:00
|
|
|
else
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -W "$checks" -- "$cur") )
|
2010-05-24 18:23:24 +02:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-04-04 22:14:39 +03:00
|
|
|
_lintian_infos()
|
|
|
|
{
|
2010-05-24 18:23:24 +02:00
|
|
|
local match search infos
|
|
|
|
|
2014-01-06 17:38:35 +02:00
|
|
|
infos=$( awk '/^Collector/ { print $2 }' \
|
|
|
|
/usr/share/lintian/collection/*.desc )
|
2010-05-24 18:23:24 +02:00
|
|
|
if [[ "$cur" == *, ]]; then
|
|
|
|
search=${cur//,/ }
|
|
|
|
for item in $search; do
|
2014-01-06 17:45:48 +02:00
|
|
|
match=$( command grep -nE "^Collector: $item$" \
|
|
|
|
/usr/share/lintian/collection/*.desc | cut -d: -f1 )
|
2011-11-26 16:08:29 +02:00
|
|
|
infos=$( sed -e "s/\<$item\>//g" <<<$infos )
|
2010-05-24 18:23:24 +02:00
|
|
|
done
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -W "$infos") )
|
2010-05-24 18:23:24 +02:00
|
|
|
elif [[ "$cur" == *,* ]]; then
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -P "${cur%,*}," -W "$infos" -- "${cur##*,}") )
|
2010-05-24 18:23:24 +02:00
|
|
|
else
|
2011-04-06 20:39:21 +03:00
|
|
|
COMPREPLY+=( $(compgen -W "$infos" -- "$cur") )
|
2010-05-24 18:23:24 +02:00
|
|
|
fi
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-04-04 22:14:39 +03:00
|
|
|
_lintian_arches()
|
|
|
|
{
|
2010-05-24 18:23:24 +02:00
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
2011-04-04 22:14:39 +03:00
|
|
|
_lintian()
|
|
|
|
{
|
2011-04-20 22:22:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-05-24 18:23:24 +02:00
|
|
|
|
2011-04-20 22:22:51 +03:00
|
|
|
local action lint_actions general_opts behaviour_opts \
|
|
|
|
configuration_opts selection_opts
|
2010-05-24 18:23:24 +02:00
|
|
|
|
2013-02-17 23:49:30 +02:00
|
|
|
lint_actions="--setup-lab --remove-lab --check --check-part --tags
|
|
|
|
--tags-from-file --ftp-master-rejects --dont-check-part --unpack
|
|
|
|
--remove"
|
2010-05-24 18:23:24 +02:00
|
|
|
general_opts="--help --version --print-version --verbose --debug --quiet"
|
2013-02-17 23:49:30 +02:00
|
|
|
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"
|
|
|
|
configuration_opts="--cfg --lab --archivedir --dist --area --section --arch
|
|
|
|
--root"
|
2010-05-24 18:23:24 +02:00
|
|
|
selection_opts="--all --binary --source --udeb --packages-file"
|
|
|
|
|
2013-04-08 23:04:11 +03:00
|
|
|
if [[ "$prev" == -* ]]; then
|
2010-05-24 18:23:24 +02:00
|
|
|
case $prev in
|
|
|
|
-C|--check-part|-X|--dont-check-part)
|
|
|
|
_lintian_checks
|
|
|
|
;;
|
|
|
|
-T|--tags|--suppress-tags)
|
|
|
|
_lintian_tags
|
|
|
|
;;
|
|
|
|
--tags-from-file|--suppress-tags-from-file|--cfg|-p|\
|
|
|
|
--packages-file)
|
|
|
|
_filedir
|
|
|
|
;;
|
|
|
|
--lab|--archivedir|--dist|--root)
|
|
|
|
_filedir -d
|
|
|
|
;;
|
|
|
|
--color)
|
|
|
|
COMPREPLY=($(compgen -W "never always auto html" -- "$cur"))
|
|
|
|
;;
|
|
|
|
-U|--unpack-info)
|
|
|
|
_lintian_infos
|
|
|
|
;;
|
|
|
|
--area|--section)
|
|
|
|
COMPREPLY=($(compgen -W "main contrib non-free" -- "$cur"))
|
|
|
|
;;
|
|
|
|
--arch)
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
fi
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
--*)
|
2013-02-17 23:49:30 +02:00
|
|
|
COMPREPLY=($(compgen -W "$lint_actions $general_opts
|
|
|
|
$behaviour_opts $configuration_opts" -- "$cur"))
|
2010-05-24 18:23:24 +02:00
|
|
|
;;
|
|
|
|
*,)
|
|
|
|
# If we're here, the user is trying to complete on
|
|
|
|
# --action tag,tag,<TAB>
|
|
|
|
# Only few actions permit that, re-complete them now.
|
|
|
|
case "$prev" in
|
|
|
|
-C|--check-part|-X|--dont-check-part)
|
|
|
|
_lintian_checks
|
|
|
|
;;
|
|
|
|
-T|--tags|--suppress-tags)
|
|
|
|
_lintian_tags
|
|
|
|
;;
|
|
|
|
-U|--unpack-info)
|
|
|
|
_lintian_infos
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_filedir '@(?(u)deb|changes|dsc)'
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return 0
|
2011-04-04 22:14:39 +03:00
|
|
|
} &&
|
|
|
|
complete -F _lintian lintian
|
2010-05-24 18:23:24 +02:00
|
|
|
|
2011-04-04 22:14:39 +03:00
|
|
|
_lintian_info()
|
|
|
|
{
|
2011-04-20 22:22:51 +03:00
|
|
|
local cur prev words cword
|
|
|
|
_init_completion || return
|
2010-05-24 18:23:24 +02:00
|
|
|
|
|
|
|
case "$prev" in
|
|
|
|
-t|--tags)
|
|
|
|
_lintian_tags
|
|
|
|
return 0
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
case "$cur" in
|
|
|
|
--*)
|
|
|
|
COMPREPLY=($(compgen -W "--annotate --help --tags" -- "$cur"))
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
_filedir
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
return 0
|
2011-04-04 22:14:39 +03:00
|
|
|
} &&
|
2010-11-01 19:26:53 +02:00
|
|
|
complete -F _lintian_info lintian-info
|
2011-04-05 22:43:29 +03:00
|
|
|
|
|
|
|
# ex: ts=4 sw=4 et filetype=sh
|