Back to all reviewers

Quote shell variables

apache/airflow
Based on 2 comments
Shell

Always quote shell script variable expansions using double quotes to prevent word splitting issues and ensure consistent behavior. This is particularly important in conditionals and when passing variables as command arguments.

Code Style Shell

Reviewer Prompt

Always quote shell script variable expansions using double quotes to prevent word splitting issues and ensure consistent behavior. This is particularly important in conditionals and when passing variables as command arguments.

Bad:

rm -rf /usr/local/lib/python${PYTHON_MAJOR_MINOR_VERSION}/site-packages/
if [[ ${UPGRADE_SQLALCHEMY=} != "true" ]]; then

Good:

rm -rf /usr/local/lib/python"${PYTHON_MAJOR_MINOR_VERSION}"/site-packages/
if [[ "${UPGRADE_SQLALCHEMY}" != "true" ]]; then

Unquoted variables can lead to unexpected behavior when they contain spaces, are empty, or include special characters. Consistently applying proper quoting improves script robustness and prevents subtle bugs that might only appear in edge cases.

2
Comments Analyzed
Shell
Primary Language
Code Style
Category

Source Discussions