Prefer mkdir p in all scripts

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the unix category.

Last Updated: 2024-11-21

Always prefer mkdir -p to mkdir in build scripts since mkdir will fail if the directory already exists (e.g. if someone is running the build script twice)

I realized this when I added mkdir to a script to sort out localhost SSL certs in a colleague's machine that didn't yet have the certs/ directory the code expected. The first run worked perfectly. However when we ran the script a second time, it broke.

Lesson

Always use mkdir -p in scripts.