fn$: _sgnd_lib_guard
Purpose
Ensure the file is sourced as a library and initialized only once.
Behavior
- Derives a unique guard variable name from the current filename.
- Aborts execution when the file is run directly instead of sourced.
- Sets the guard variable on first load.
- Returns immediately when the library was already loaded.
Inputs BASH_SOURCE[0] $0
Outputs (globals) SGND_<MODULE>_LOADED
Returns
0 when already loaded or successfully initialized. Exits with code 2 when executed instead of sourced.
Usage
_sgnd_lib_guard
