bash::framehead follows a modular architecture that compiles into a single sourceable file. The framework consists of 16 independent modules organized in the src/ directory, each providing a focused set of functionality following the module::function naming convention.
Most modules are designed to be independent, with one critical exception:
runtime.sh is required — all other modules depend on it for environment detection via functions like runtime::has_command and runtime::is_minimum_bash.
Concatenate all module files, stripping shebangs from all files except the first.
main.sh:66-75
while IFS= read -r line; do # Strip shebang from all but the first file if (( i > 0 && i_line == 0 )); then (( i_line++ )) [[ "$line" =~ ^#! ]] && continue fi printf '%s\n' "$line" >> "$output_file" (( i_line++ ))done < "$func_file"
4
Output finalization
Make the output file executable and report compilation statistics.
main.sh:88-96
chmod +x "$output_file" 2>/dev/nullecho "Compiled $i file(s) to $output_file${final_issue_str}"
When you source the compiled file, all ~785 functions are loaded into the current shell’s namespace. The framework includes a statistics function to measure load performance:
main.sh:109-118
echo "=== Testing load time in fresh shell ==="command time -f "Real: %e s, User: %U s, Sys: %S s" \ bash -c "source $file"echo "=== Function count by module ==="( source $file declare -F | awk -F'::' '{print $1}' | sort | uniq -c | sort -rn echo "$(declare -F | wc -l) total functions loaded")
Load time is typically under 0.1 seconds on modern hardware, making the framework suitable for both interactive scripts and automation.
The framework prioritizes pure Bash implementations where practical:
src/string.sh:93-95
# Convert to uppercasestring::upper() { echo "${1^^}"}
When external tools are required (like bc for floating point math), functions check availability first:
src/math.sh:37-44
math::bc() { local expr="$1" scale="${2:-$MATH_SCALE}" if ! math::has_bc; then echo "math::bc: requires bc (GNU coreutils)" >&2 return 1 fi echo "scale=${scale}; ${expr}" | bc -l}
This ensures scripts fail gracefully with actionable error messages rather than cryptic command-not-found errors.