Shell Boilerplate
wget https://raw.githubusercontent.com/yvoronoy/shell-boilerplate/master/script.sh
Usage: script.sh [action name] [--options] []
You can specify your own action for example helloworld
helloworldAction()
{
echo "Hello World!";
}
and run it script.sh helloworld
That's it.
- Use two spaces instead tab.
- Use ; at the end of line.
- Use {} to enclose your variables.
- Use :- if you want to test variables that could be undeclared. For instance, with if [ "${NAME:-}" = "Kevin" ],
$NAME will evaluate to Kevin if the variable is empty. The variable itself will remain unchanged. The syntax to assign a default value is $ {NAME:=Kevin}.