Bash Parameter Expansion Syntax

Wednesday, July 22, 2026

I was in the middle of trying to understand a certain CI process and was wondering if there's a null-colaescing operator in bash. That's when I learned bash parameter expansion syntax.


It's pretty simple, but powerful.

${VARIABLE:-default_value}

Basically, if VARIABLE is not defined, then it will use default_value. In the CI pipeline that I encountered, it is used as follow:

${PROJECT_PATH:-.}

So, if PROJECT_PATH is not defined, just default to the current directory.