We are using Google's Shell Style Guide with some exceptions:
-
use POSIX shell (
#!/bin/sh
). Check official guide, hints from ubuntu team, hints from GreyCat and tricks. Unittest.sh should work in: bash, zsh, dash and posh. -
use shellcheck and checkbashisms.
-
functions name in format:
ut_<namespace>__<function_name>
(eg. ut_parser__find_functions) -
local variable are normal variables (without
local
ortypeset
declaration - POSIX!) but have special names:ut<hash>__<local_variable_name>
where<hash>
is first 3 character of sha1 sum of function name (eg. utac4__message inside of ut_msg__error() function). You can easily generate hash in terminal with command:echo "function_name" | sha1sum | cut -c -3