It’s always a bit confusing to reason about which startup files bash(1) is going to run in a given situation. It is documented, but the logic is not trivial.

So I made a chart (using PlantUML!). You’re welcome.

EDIT: There is also one for zsh(1) (PlantUML).

The main takeaway from this exercise is:

In sh mode, bash and zsh do slightly different things.

Bash

An activity diagram showing which startup files are processed by `bash` depending on context.
Graphical representation of bash‘s startup logic.

Zsh

Sure enough, as soon as I shared this post. Someone chimed in asking for a version for zsh(1). As I suspected, it is equally hairy, but certainly different in incompatible ways.

An activity diagram showing which startup files are processed by `zsh` depending on context.
Graphical representation of zsh‘s startup logic.

Leave a Reply