Files
impala/testdata/bin/run-hive.sh
Casey Ching cfb1ab5c2c IMPALA-2781: Fix shell error reporting after chdir
The original error reporting relied on $0 being accessible from the
current working dir, which failed if a script changed the working dir
and $0 was relative. This updates the error reporting command to cd back
to the original dir before accessing $0.

Change-Id: I2185af66e35e29b41dbe1bb08de24200bacea8a1
Reviewed-on: http://gerrit.cloudera.org:8080/1666
Reviewed-by: Casey Ching <casey@cloudera.com>
Tested-by: Internal Jenkins
2016-01-14 07:10:54 +00:00

24 lines
616 B
Bash
Executable File

#!/bin/bash
set -euo pipefail
trap 'echo Error in $0 at line $LINENO: $(cd "'$PWD'" && awk "NR == $LINENO" $0)' ERR
CONF_DIR=$1
SCRIPT=$2
WH=$3
MS_URL=$4
MS_DRIVER=$5
MS_USERNAME=$6
MS_PASSWORD=$7
HIVE="hive "
HIVE="$HIVE -hiveconf \"test.hive.warehouse.dir=$WH\""
HIVE="$HIVE -hiveconf \"test.hive.metastore.jdbc.url=$MS_URL\""
HIVE="$HIVE -hiveconf \"test.hive.metastore.jdbc.driver=$MS_DRIVER\""
HIVE="$HIVE -hiveconf \"test.hive.metastore.jdbc.username=$MS_USERNAME\""
HIVE="$HIVE -hiveconf \"test.hive.metastore.jdbc.password=$MS_PASSWORD\""
HIVE_CONF_DIR=$CONF_DIR
export HIVE_CONF_DIR
$HIVE -f $SCRIPT -v