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.

Graphical representation of zsh‘s startup logic.

Update 2023-03-13: Fixed confusion between zshrc (interactive) and zlogin (login).

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.