mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-21 07:39:08 +01:00
lint: Do not allow locale dependent shell scripts
Bash is discouraged, and there was never a need to write locale dependent Bash. So remove the option and clarify that the LC_ALL settings enable UTF-8 mode in Python.
This commit is contained in:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user