In short: be consistent with existing code.
- indentation: 1 tab (smaller script size than 4 spaces; consistent with
cat <<-EOF
idiom) - use POSIX shell syntax.
unittest
meant to be able to run on any POSIX-compliant system. See more: - functions that don't modify global variables should be defined as subshells
(with body inside
()
),e.g.some_func() ( ... )
. This simplify variable lifecycle management - functions that modify global variables should be defined as curly braces
functions (with body inside
{}
), e.g.some_func() { ... }
. All variables defined inside function are global, so they should be unset after use, e.g.unset -v ut_somevar
- function names are lowercase with unittest__ prefix,
e.g.
unittest__print_result
- global variable names are uppercase with UT_ prefix, e.g.
UT_VERSION
- local variable names inside curly braces functions are lowercase with ut_
prefix, e.g.
ut_i