Shell Library Design
Function Prefix
Name Helpers
A small prefix keeps library helper names grouped and reduces accidental collisions with script-level functions.
Program
Play the script to choose the prefix and see the generated helper-style name.
library_function_prefix.sh
Replay: real traced execution (multi-file project)
#!/usr/bin/env bash
lib_prefix="app"
helper="start"
function_name="${lib_prefix}_${helper}"
echo "$function_name"
#!/usr/bin/env bash
lib_prefix="deploy"
helper="start"
function_name="${lib_prefix}_${helper}"
echo "$function_name"
lib_prefix ← app
3lib_prefix="app"4helper="start"values this stepapplib_prefixhelper ← start
3lib_prefix="app"4helper="start"5function_name="${lib_prefix}_${helper}"values this stepstarthelperfunction_name ← app_start
4helper="start"5function_name="${lib_prefix}_${helper}"6echo "$function_name"values this stepapp_startfunction_nameapplib_prefixstarthelperecho "$function_name"
5function_name="${lib_prefix}_${helper}"6echo "$function_name"outputapp_startvalues this stepapp_startfunction_name
lib_prefix ← deploy
3lib_prefix="deploy"4helper="start"values this stepdeploylib_prefixhelper ← start
3lib_prefix="deploy"4helper="start"5function_name="${lib_prefix}_${helper}"values this stepstarthelperfunction_name ← deploy_start
4helper="start"5function_name="${lib_prefix}_${helper}"6echo "$function_name"values this stepdeploy_startfunction_namedeploylib_prefixstarthelperecho "$function_name"
5function_name="${lib_prefix}_${helper}"6echo "$function_name"outputdeploy_startvalues this stepdeploy_startfunction_name
name prefix
A prefix groups related helper names together.
collision avoidance
Distinct helper names reduce clashes with caller scripts.
library convention
A naming convention is part of the library's public contract.