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 bash3# Based on realpath.sh written by Michael Kropat4# Found at: https://github.com/mkropat/sh-realpath/blob/65512368b8155b176b67122aa395ac580d9acc5b/realpath.sh6bash_realpath() {7canonicalize_path "$(resolve_symlinks "$1")"8}10resolve_symlinks() {11_resolve_symlinks "$1"12}14_resolve_symlinks() {15_assert_no_path_cycles "$@" || return17local dir_context path18if path=$(readlink -- "$1"); then19dir_context=$(dirname -- "$1")20_resolve_symlinks "$(_prepend_dir_context_if_necessary "$dir_context" "$path")" "$@"21else22printf '%s\n' "$1"23fi24}26_prepend_dir_context_if_necessary() {27if [ "$1" = . ]; then28printf '%s\n' "$2"29else30_prepend_path_if_relative "$1" "$2"31fi32}34_prepend_path_if_relative() {35case "$2" in36/* ) printf '%s\n' "$2" ;;37* ) printf '%s\n' "$1/$2" ;;38esac39}41_assert_no_path_cycles() {42local target path44target=$145shift47for path in "$@"; do48if [ "$path" = "$target" ]; then49return 150fi51done52}54canonicalize_path() {55if [ -d "$1" ]; then56_canonicalize_dir_path "$1"57else58_canonicalize_file_path "$1"59fi60}62_canonicalize_dir_path() {63(cd "$1" 2>/dev/null && pwd -P)64}66_canonicalize_file_path() {67local dir file68dir=$(dirname -- "$1")69file=$(basename -- "$1")70(cd "$dir" 2>/dev/null && printf '%s/%s\n' "$(pwd -P)" "$file")71}
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.