Fix a substitution bug when hostname -d is empty.