diff --git a/bin/beeline b/bin/beeline index 7b974d4..d247c39 100644 --- a/bin/beeline +++ b/bin/beeline @@ -18,9 +18,4 @@ bin=`dirname "$0"` bin=`cd "$bin"; pwd` -# If process is backgrounded, don't change terminal settings -if [[ ( ! $(ps -o stat= -p $$) =~ "+" ) && ! ( -p /dev/stdin ) ]]; then - export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Djline.terminal=jline.UnsupportedTerminal" -fi - . "$bin"/hive --service beeline "$@" diff --git a/bin/ext/beeline.sh b/bin/ext/beeline.sh index 8052c45..a2fb659 100644 --- a/bin/ext/beeline.sh +++ b/bin/ext/beeline.sh @@ -32,6 +32,8 @@ beeline () { export HADOOP_CLASSPATH="${hadoopClasspath}${HIVE_CONF_DIR}:${beelineJarPath}:${superCsvJarPath}:${jlineJarPath}" export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dlog4j.configurationFile=beeline-log4j2.properties " + checkRunInBackground + exec $HADOOP jar ${beelineJarPath} $CLASS $HIVE_OPTS "$@" } diff --git a/bin/ext/cli.sh b/bin/ext/cli.sh index 4933c2e..5d906ec 100644 --- a/bin/ext/cli.sh +++ b/bin/ext/cli.sh @@ -22,13 +22,6 @@ if [ -z "$USE_DEPRECATED_CLI" ] || [ "$USE_DEPRECATED_CLI" != "false" ]; then USE_DEPRECATED_CLI="true" fi -updateBeelineOpts() { - # If process is backgrounded, don't change terminal settings - if [[ ( ! $(ps -o stat= -p $$) =~ *+ ) && ! ( -p /dev/stdin ) ]]; then - export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Djline.terminal=jline.UnsupportedTerminal" - fi -} - updateCli() { if [ "$USE_DEPRECATED_CLI" == "true" ]; then CLASS=org.apache.hadoop.hive.cli.CliDriver @@ -37,12 +30,12 @@ updateCli() { export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Dlog4j.configurationFile=beeline-log4j2.properties" CLASS=org.apache.hive.beeline.cli.HiveCli JAR=hive-beeline-*.jar - updateBeelineOpts fi } cli () { updateCli + checkRunInBackground execHiveCmd $CLASS $JAR "$@" } diff --git a/bin/ext/hiveserver2.sh b/bin/ext/hiveserver2.sh index c17452c..b423c8d 100644 --- a/bin/ext/hiveserver2.sh +++ b/bin/ext/hiveserver2.sh @@ -24,6 +24,8 @@ hiveserver2() { fi JAR=${HIVE_LIB}/hive-service-[0-9].*.jar + checkRunInBackground + exec $HADOOP jar $JAR $CLASS $HIVE_OPTS "$@" } diff --git a/bin/ext/util/checkRunInBackground.sh b/bin/ext/util/checkRunInBackground.sh new file mode 100644 index 0000000..263dc1c --- /dev/null +++ b/bin/ext/util/checkRunInBackground.sh @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +checkRunInBackground () { + # If process is backgrounded, don't change terminal settings + if [[ ( ! $(ps -o stat= -p $$) =~ "+" ) && ! ( -p /dev/stdin ) ]]; then + export HADOOP_CLIENT_OPTS="$HADOOP_CLIENT_OPTS -Djline.terminal=jline.UnsupportedTerminal" + fi +}