#!/bin/bash
# (Copyright) [2019 - 2019] Confluent, Inc.

 #
# Use shellcheck to lint this file
#
set -ue

 base_dir=$( cd "$( dirname "${BASH_SOURCE[0]}" )/.." && pwd )
if [ "$base_dir" = "/" ]; then
    base_dir=""
fi
: "${KSQL_CONFIG_DIR:="$base_dir/config"}"

 : "${KSQL_LOG4J_OPTS:=""}"
if [ -z "$KSQL_LOG4J_OPTS" ] && [ -e "$KSQL_CONFIG_DIR/log4j-sql-test.yaml" ]; then
  export KSQL_LOG4J_OPTS="-Dlog4j2.configurationFile=file:$KSQL_CONFIG_DIR/log4j-sql-test.yaml"
fi

 exec "$base_dir"/bin/ksql-run-class io.confluent.ksql.tools.test.SqlTestingTool "$@"