summaryrefslogtreecommitdiff
path: root/tests/test_duplicate_mime_types.sh
blob: e7dfb150a9a28aed9ded70f75d707c019caf256c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/usr/bin/env bash
set -euo pipefail

: ${1:?filename argument missing}
xml_db_file="${1}"
test -f ${xml_db_file} || {
    printf "%s: no such file\n" ${xml_db_file} >&2
    exit 1
}

duplicated=$(
    xmllint --xpath \
            "//*[local-name()='mime-type' or local-name()='alias']/@type" \
            ${xml_db_file} | tr ' ' '\n' | sort | uniq -d
)

if [[ -n "${duplicated}" ]]; then
    echo "*************************************************************"
    echo "** Some mime-types are duplicated, fix before committing:  **"
    echo "${duplicated}"
    echo "*************************************************************"
    exit 1
fi