Skip to content

Instantly share code, notes, and snippets.

@colemar
Last active December 16, 2025 18:06
Show Gist options
  • Select an option

  • Save colemar/cef6c8c2b13b1da50338d1ce934ee591 to your computer and use it in GitHub Desktop.

Select an option

Save colemar/cef6c8c2b13b1da50338d1ce934ee591 to your computer and use it in GitHub Desktop.
Bash Variable States Matrix

Bash Variable States Matrix

Command declare -p var [[ -v var ]] set +u; [[ $var ]]
set -u; [[ ${var:-} ]]
set -u; [[ $var ]]
unset var FALSE ($?==1) FALSE FALSE CRASH (unbound)
declare var var FALSE FALSE CRASH (unbound)
declare var= var="" TRUE FALSE FALSE
declare var=1 var="1" TRUE TRUE TRUE
@colemar
Copy link
Author

colemar commented Dec 16, 2025

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment