]> git.ipfire.org Git - thirdparty/util-linux.git/blame - tools/checkcompletion.sh
Merge branch 'container' of https://github.com/slashdd/util-linux
[thirdparty/util-linux.git] / tools / checkcompletion.sh
CommitLineData
5ae7ae8a
KZ
1#!/bin/bash
2
3#
4# This script checks if we have bash-completion scripts for the all compiled
5# binaries.
6#
7# Copyright (C) 2016 Karel Zak <kzak@redhat.com>
8#
9
10
11die() {
12 echo "error: $1"
13 exit 1
14}
15
16usage() {
17 echo "Usage:"
18 echo " $0 [<top_srcdir>]"
19}
20
21# unwanted scripts -- use grep -E, e.g. (aaa|bbb|ccc)
22completion_exclude="(nologin)"
23
24top_srcdir=${1-"."}
25completion_dir="${top_srcdir}/bash-completion"
26
27[ -d "${completion_dir}" ] || die "not found ${completion_dir}"
28
29bin_files=$(cd ${top_srcdir} && find * -maxdepth 0 -perm /u+x \
30 \! -type d \
31 \! -name \*.sh \! -name \*.cache \! -name \*.status \
32 \! -name configure \! -name libtool | sort)
33
34completion_files=$(cd ${completion_dir}/ && find * ! -name '*.am' | sort -u)
35completion_missing=$(comm -3 <(echo "$completion_files") <(echo "$bin_files"))
36
37if [ -n "$completion_missing" -a -n "$completion_exclude" ]; then
38 completion_missing=$(echo "$completion_missing" | grep -v -E "$completion_exclude")
39fi
40
41if [ -n "$completion_missing" ]; then
42 echo "Missing completion scripts:"
43 echo "$completion_missing"
44fi
45