Skip to content

Instantly share code, notes, and snippets.

@goddoe
Created June 1, 2022 15:26
Show Gist options
  • Select an option

  • Save goddoe/77469e930348248ba6d72014354f853f to your computer and use it in GitHub Desktop.

Select an option

Save goddoe/77469e930348248ba6d72014354f853f to your computer and use it in GitHub Desktop.
right way to check var is unset
# Reference: https://stackoverflow.com/questions/3601515/how-to-check-if-a-variable-is-set-in-bash
if [ -z ${var+x} ]; then echo "var is unset"; else echo "var is set to '$var'"; fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment