Shell
What shell
If you’re building a very simple shell script, use the most compatible
shell: sh
. If you need a bit more power, use bash
.
Some developers often use more fancy shells, but for the sake of
simplicity, please stick with bash
. We don’t want to force all developers in
a project to learn this years fancy shell. If you need more fancy things, consider
using a scripting language like python
instead.
Boilerplate
To make bash scripts behave as we’d expect, some boilerplate is needed.
- Stop on any kind of failure
- Echo the commands run (convenient to debug a failing CI job)
So, start a bash script using:
#!/bin/bashset -eoxu pipefail
See explainshell.com for what it does.
Linting
Make sure you shell scripts are linted using shellcheck
. You could use
shfmt
as a formatter in local development.