sh Coding Style
Abstract
cat << END
set -e
snake_case() {
local foo=bar
some-command --long-option "$foo"
}
END | dash
Naming
We prefer hyphen-word
over snake_case
over CamelCase
.
However, dash
only allows _
and alnum as variable names.
Thus, snake_case
is preferred.
Short options
We prefer --long
for self-documentation.
Compatibility
Test against dash.
Fails early
Use set -e
.
Local variable
Use local
variables in function definitions when possible.