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.

lib_prefix
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"
  1. lib_prefix ← app

    3lib_prefix="app"4helper="start"
    values this stepapplib_prefix
  2. helper ← start

    3lib_prefix="app"4helper="start"5function_name="${lib_prefix}_${helper}"
    values this stepstarthelper
  3. function_name ← app_start

    4helper="start"5function_name="${lib_prefix}_${helper}"6echo "$function_name"
    values this stepapp_startfunction_nameapplib_prefixstarthelper
  4. echo "$function_name"

    5function_name="${lib_prefix}_${helper}"6echo "$function_name"
    outputapp_start
    values this stepapp_startfunction_name
  1. lib_prefix ← deploy

    3lib_prefix="deploy"4helper="start"
    values this stepdeploylib_prefix
  2. helper ← start

    3lib_prefix="deploy"4helper="start"5function_name="${lib_prefix}_${helper}"
    values this stepstarthelper
  3. function_name ← deploy_start

    4helper="start"5function_name="${lib_prefix}_${helper}"6echo "$function_name"
    values this stepdeploy_startfunction_namedeploylib_prefixstarthelper
  4. echo "$function_name"

    5function_name="${lib_prefix}_${helper}"6echo "$function_name"
    outputdeploy_start
    values 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.