Actually I think it works as intended: if USER_CMSSW_REPO is not defined or empty, 
 - "$USER_CMSSW_REPO" evaluates to ""
 - [ "" ] evaluates to false
 - and the if-branch is skipped.

It would not work without the double quotes (if [ $USER_CMSSW_REPO ] ...).

At least, I've tried adding 
unset USER_CMSSW_REPO
just before the if, and it behaves correctly.

.A