diff options
author | practicalswift <practicalswift@users.noreply.github.com> | 2018-06-13 16:30:47 +0200 |
---|---|---|
committer | practicalswift <practicalswift@users.noreply.github.com> | 2018-06-14 15:27:52 +0200 |
commit | 47776a958b08382d76d69b5df7beed807af168b3 (patch) | |
tree | 6744a97d0ae8041f4549cd8214247ac5ffa406ea /test | |
parent | 3352da8da1243c03fc83ba678d2f5d193bd5a0c2 (diff) |
Add linter: Make sure all shell scripts opt out of locale dependence using "export LC_ALL=C"
Diffstat (limited to 'test')
-rwxr-xr-x | test/lint/lint-shell-locale.sh | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/lint/lint-shell-locale.sh b/test/lint/lint-shell-locale.sh new file mode 100755 index 0000000000..d78bac2d47 --- /dev/null +++ b/test/lint/lint-shell-locale.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# +# Copyright (c) 2018 The Bitcoin Core developers +# Distributed under the MIT software license, see the accompanying +# file COPYING or http://www.opensource.org/licenses/mit-license.php. +# +# Make sure all shell scripts: +# a.) explicitly opt out of locale dependence using "export LC_ALL=C", or +# b.) explicitly opt in to locale dependence using the annotation below. + +export LC_ALL=C + +EXIT_CODE=0 +for SHELL_SCRIPT in $(git ls-files -- "*.sh" | grep -vE "src/(secp256k1|univalue)/"); do + if grep -q "# This script is intentionally locale dependent by not setting \"export LC_ALL=C\"" "${SHELL_SCRIPT}"; then + continue + fi + FIRST_NON_COMMENT_LINE=$(grep -vE '^(#.*|)$' "${SHELL_SCRIPT}" | head -1) + if [[ ${FIRST_NON_COMMENT_LINE} != "export LC_ALL=C" ]]; then + 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} |