Bash - elventear/devops GitHub Wiki

Bash

Bash is available in all modern systems. Bash has also evolved with new syntax that fixes many of the word splitting and substitution problems.

Dockerization

Docker has turned Bash into a maintstream programming language. Bash is the only programming language available on all distros, even busybox. That means that Dockerfiles are essentially bash scripts. Entry points are bash scripts. And so on.

However people have not embraced bash. The Docker hub doesn't allow you to build from a bash script. It relies on a Dockerfile existing. This yields very awkward Dockerfile/bash code.

Also, people don't understand how to use Bash well so they are using a mix of modern and old versions. Anything using Docker is building with a modern distro, which has Bash 4.2 or 4.3.

Docker allows us to rely on modern bash.

Modularization

C is still a popular programming language. There are no name spaces, and neither are there in Bash. That's ok. Just be disciplined as in C.

Imports can then just use source (.).

Problems

Bug in unbound variables?

$ set -e
$ set -u
$ x=([y]=1)
bash: y: unbound variable

You can't even do this:

$ x[y]=1
bash: y: unbound variable

Useful Links

http://mywiki.wooledge.org/BashPitfalls