This ternary operator seems off. If $HOME is not empty, then shouldn't you use that, instead of $HOMEDRIVE?

Both $HOMEDRIVE and $HOMEPATH are empty on my OS X machine, for example (also, I've never encountered them before).