Beeline will return non-zero exit code on failure in the following CDH versions 5.2.2 onwards.
The returned exit code simply means the number of errors occurred during beeline’s execution. So for example, the following command will result the exit code of 2 because the first two “show” command will fail and last one will succeed:
beeline -u jdbc:hive2://localhost:10000 -e "show table" -e "show t" -e "show tables"
In the bash script environment, the exit code is the only way to catch beeline’s failure reliably.