Description
https://github.com/apache/hive/blob/trunk/hcatalog/bin/hcat#L81
The quoted snippet (see below) intends to set HIVE_HOME if it's not set (i.e. HIVE_HOME is currently null).
if [ -n ${HIVE_HOME} ]; then
However, -n checks if the variable is not null. So, the above code ends up setting HIVE_HOME to the default value if it is actually set already, overriding the set value. This condition needs to be negated.
Moreover, -n checks requires the string being tested to be enclosed in quotes.