2018-06-20 02:54:54 -07:00
|
|
|
#!/usr/bin/env bash
|
2018-06-13 07:30:47 -07:00
|
|
|
#
|
|
|
|
# Copyright (c) 2018 The Bitcoin Core developers
|
|
|
|
# Distributed under the MIT software license, see the accompanying
|
2020-12-12 16:33:22 -08:00
|
|
|
# file COPYING or https://www.opensource.org/licenses/mit-license.php .
|
2018-06-13 07:30:47 -07:00
|
|
|
#
|
|
|
|
# Make sure all shell scripts:
|
2018-08-07 02:50:05 -07:00
|
|
|
# a.) explicitly opt out of locale dependence using
|
|
|
|
# "export LC_ALL=C" or "export LC_ALL=C.UTF-8", or
|
2018-06-13 07:30:47 -07:00
|
|
|
# b.) explicitly opt in to locale dependence using the annotation below.
|
|
|
|
|
|
|
|
export LC_ALL=C
|
|
|
|
|
|
|
|
EXIT_CODE=0
|
2020-11-09 12:06:45 -08:00
|
|
|
for SHELL_SCRIPT in $(git ls-files -- "*.sh"); do
|
2020-11-09 09:15:46 -08:00
|
|
|
if grep -q "# This script is intentionally locale-dependent by not setting \"export LC_ALL=C\"." "${SHELL_SCRIPT}"; then
|
2018-06-13 07:30:47 -07:00
|
|
|
continue
|
|
|
|
fi
|
2018-08-30 15:52:48 -07:00
|
|
|
FIRST_NON_COMMENT_LINE=$(grep -vE '^(#.*)?$' "${SHELL_SCRIPT}" | head -1)
|
2020-10-28 06:19:27 -07:00
|
|
|
if [[ ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C" && ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=\"C\"" && ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C.UTF-8" ]]; then
|
2018-06-13 07:30:47 -07:00
|
|
|
echo "Missing \"export LC_ALL=C\" (to avoid locale dependence) as first non-comment non-empty line in ${SHELL_SCRIPT}"
|
|
|
|
EXIT_CODE=1
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
exit ${EXIT_CODE}
|