lint: Do not allow locale dependent shell scripts
What changed, and why it matters
This is a minor change to a linting script that checks shell scripts for locale settings. It removes an optional opt-out for locale-dependent scripts and clarifies documentation. There is no security-relevant change to Bitcoin Core's runtime behavior, consensus code, or network handling.
No action required. This is a non-security linting policy change.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies test/lint/lint-shell-locale.py to remove the ability for shell scripts to opt in to locale dependence via a special comment annotation. The lint now requires all shell scripts to set ‘export LC_ALL=C’ or ‘export LC_ALL=C.UTF-8’. The change is purely a development tooling/linting policy update. No executable shell scripts are changed, no runtime code is changed, and no security boundary is affected.
Changed components
test/lint/lint-shell-locale.pyInspect captured patch +4 / −10
diff --git a/test/lint/lint-shell-locale.py b/test/lint/lint-shell-locale.py
index 309c4263..59515e78 100755
--- a/test/lint/lint-shell-locale.py
+++ b/test/lint/lint-shell-locale.py
@@ -1,22 +1,19 @@
#!/usr/bin/env python3
#
-# Copyright (c) 2018-2022 The Bitcoin Core developers
+# Copyright (c) 2018-present 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 are:
-a.) explicitly opt out of locale dependence using
- "export LC_ALL=C" or "export LC_ALL=C.UTF-8", or
-b.) explicitly opt in to locale dependence using the annotation below.
+Make sure all shell scripts explicitly opt out of locale dependence using
+"export LC_ALL=C" or "export LC_ALL=C.UTF-8", which also enables UTF-8 mode in
+Python. See: https://docs.python.org/3/library/os.html#python-utf-8-mode
"""
import subprocess
import sys
import re
-OPT_IN_LINE = '# This script is intentionally locale dependent by not setting \"export LC_ALL=C\"'
-
OPT_OUT_LINES = [
'export LC_ALL=C',
'export LC_ALL=C.UTF-8',
@@ -47,9 +44,6 @@ def main():
with open(file_path, 'r', encoding='utf-8') as file_obj:
contents = file_obj.read()
- if OPT_IN_LINE in contents:
- continue
-
non_comment_pattern = re.compile(r'^\s*((?!#).+)$', re.MULTILINE)
non_comment_lines = re.findall(non_comment_pattern, contents)
if not non_comment_lines:
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.