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.
And if #Do stuf in temp dir happens to be one of those mosters which change working dir you could be anywhere. Having the directory shown in your prompt solves most of that though
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.