Super_Programmer
Super_Programmer

Reputation: 7

Enviroment variable with brackets in Linux?

I try to understand this following example in the brackets.

AIRFLOW_PROJ_DIR 

is an enviroment variable which will be called by the $ symbol outside of the bracket. But I have problems to understand the part after the enviroment variable. What is the meaning of these inside the brackets?

:-.
 ${AIRFLOW_PROJ_DIR:-.}/dags

I tried to google it up and looked in forums for help.

Upvotes: -4

Views: 61

Answers (1)

Brandon Lotero
Brandon Lotero

Reputation: 36

What you are describing is called as shell parameter expansion. This means that on evaluation time, bash searches the value of the variable and if not found, would assign the value at the right of :-.

In other words, if AIRFLOW_PROJ_DIR variable is defined (and its value is e.g. /home/me/airflow/project), then your expression would evaluate as /home/me/airflow/project/dags, otherwise, if not defined it will be evaluated as ./dags.

More on shell parameter expansion at: https://www.gnu.org/software/bash/manual/html_node/Shell-Parameter-Expansion.html

Upvotes: 2

Related Questions