Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1#!/usr/bin/env python32#3# Copyright (c) 2018-present The Bitcoin Core developers4# Distributed under the MIT software license, see the accompanying5# file COPYING or http://www.opensource.org/licenses/mit-license.php.7"""8Make sure all shell scripts explicitly opt out of locale dependence9using "export LC_ALL=C.UTF-8", which also enables UTF-8 mode in10Python. See: https://docs.python.org/3/library/os.html#python-utf-8-mode11"""13import subprocess14import sys15import re17OPT_OUT_LINES = [18'export LC_ALL=C.UTF-8',19]21def get_shell_files_list():22command = [23'git',24'ls-files',25'--',26'*.sh',27]28try:29return subprocess.check_output(command, stderr = subprocess.STDOUT, text=True).splitlines()30except subprocess.CalledProcessError as e:31if e.returncode > 1: # return code is 1 when match is empty32print(e.output, end='')33sys.exit(1)34return []36def main():37exit_code = 038shell_files = get_shell_files_list()39for file_path in shell_files:40if re.search('src/(ipc/libmultiprocess|secp256k1|minisketch)/', file_path):41continue43with open(file_path, 'r') as file_obj:44contents = file_obj.read()46non_comment_pattern = re.compile(r'^\s*((?!#).+)$', re.MULTILINE)47non_comment_lines = re.findall(non_comment_pattern, contents)48if not non_comment_lines:49continue51first_non_comment_line = non_comment_lines[0]52if first_non_comment_line not in OPT_OUT_LINES:53print(f'Missing "export LC_ALL=C.UTF-8" (to avoid locale dependence) as first non-comment non-empty line in {file_path}')54exit_code = 156return sys.exit(exit_code)58if __name__ == '__main__':59main()
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.