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"""8Check for shellcheck warnings in shell scripts.9"""11import subprocess12import re13import sys15# Disabled warnings:16DISABLED = [17'SC2162', # read without -r will mangle backslashes.18]20def check_shellcheck_install():21try:22subprocess.run(['shellcheck', '--version'], stdout=subprocess.DEVNULL, check=True)23except FileNotFoundError:24print('Skipping shell linting since shellcheck is not installed.')25sys.exit(0)27def get_files(command):28output = subprocess.run(command, stdout=subprocess.PIPE, text=True)29files = output.stdout.split('\n')31# remove whitespace element32files = list(filter(None, files))33return files35def main():36check_shellcheck_install()38# build the `exclude` flag39exclude = '--exclude=' + ','.join(DISABLED)41# build the `sourced files` list42sourced_files_cmd = [43'git',44'grep',45'-El',46r'^# shellcheck shell=',47]48sourced_files = get_files(sourced_files_cmd)50# build the `guix files` list51guix_files_cmd = [52'git',53'grep',54'-El',55r'^#!\/usr\/bin\/env bash',56'--',57'contrib/guix',58'contrib/shell',59]60guix_files = get_files(guix_files_cmd)62# build the other script files list63files_cmd = [64'git',65'ls-files',66'--',67'*.sh',68]69files = get_files(files_cmd)70reg = re.compile(r'src/[leveldb,secp256k1,minisketch]')72def should_exclude(fname: str) -> bool:73return bool(reg.match(fname))75# remove everything that doesn't match this regex76files[:] = [file for file in files if not should_exclude(file)]78# build the `shellcheck` command79shellcheck_cmd = [80'shellcheck',81'--external-sources',82'--check-sourced',83'--source-path=SCRIPTDIR',84]85shellcheck_cmd.append(exclude)86shellcheck_cmd.extend(sourced_files)87shellcheck_cmd.extend(guix_files)88shellcheck_cmd.extend(files)90# run the `shellcheck` command91try:92subprocess.check_call(shellcheck_cmd)93except subprocess.CalledProcessError:94sys.exit(1)96if __name__ == '__main__':97main()
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.