It's just a huge design mistake to treat "missing" like an empty string in env vars. In many cases referencing a missing var should be an error, not a silent conversion to an empty string.
It's funny how many of us would never use a weakly/stringly typed language to handle our important data, but then we happily use bash to deploy or manage the systems on which our apps run.
cd $TempDIR
wget http://example.com #Do stuf in temp dir
rm -R . #Clean Tempdit
if $TempDIR is not set, it will delete your home directory.
If $TempDIR does not exist or the cd somehow fails it will delete your current folder.