Skip to content

Commit 8493a9e

Browse files
committed
Using eval to retain quoted arguments
1 parent aed523f commit 8493a9e

File tree

2 files changed

+23
-17
lines changed

2 files changed

+23
-17
lines changed

bin/spark-sql

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,31 +58,37 @@ if [[ "$@" = --help ]] || [[ "$@" = -h ]]; then
5858
exit 0
5959
fi
6060

61-
CLI_ARGS=""
62-
SUBMISSION_ARGS=""
61+
CLI_ARGS=()
62+
SUBMISSION_ARGS=()
6363

6464
while (($#)); do
65-
case $1 in
66-
-d | --define | --database | -e | -f | -h | --hiveconf | --hivevar | -i | -p)
65+
case $1 in
66+
-d | --define | --database | -f | -h | --hiveconf | --hivevar | -i | -p)
6767
ensure_arg_number $# 2
68-
CLI_ARGS+=" $1"; shift
69-
CLI_ARGS+=" $1"; shift
68+
CLI_ARGS+=($1); shift
69+
CLI_ARGS+=($1); shift
70+
;;
71+
72+
-e)
73+
ensure_arg_number $# 2
74+
CLI_ARGS+=($1); shift
75+
CLI_ARGS+=(\"$1\"); shift
7076
;;
7177

7278
-s | --silent)
73-
CLI_ARGS+=" $1"; shift
79+
CLI_ARGS+=($1); shift
7480
;;
7581

7682
-v | --verbose)
7783
# Both SparkSubmit and SparkSQLCLIDriver recognizes -v | --verbose
78-
CLI_ARGS+=" $1"
79-
SUBMISSION_ARGS+=" $1"; shift
84+
CLI_ARGS+=($1)
85+
SUBMISSION_ARGS+=($1); shift
8086
;;
8187

8288
*)
83-
SUBMISSION_ARGS+=" $1"; shift
89+
SUBMISSION_ARGS+=($1); shift
8490
;;
8591
esac
8692
done
8793

88-
exec "$FWDIR"/bin/spark-submit --class $CLASS $SUBMISSION_ARGS spark-internal $CLI_ARGS
94+
eval exec "$FWDIR"/bin/spark-submit --class $CLASS ${SUBMISSION_ARGS[*]} spark-internal ${CLI_ARGS[*]}

sbin/start-thriftserver.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,21 +58,21 @@ if [[ "$@" = --help ]] || [[ "$@" = -h ]]; then
5858
exit 0
5959
fi
6060

61-
THRIFT_SERVER_ARGS=""
62-
SUBMISSION_ARGS=""
61+
THRIFT_SERVER_ARGS=()
62+
SUBMISSION_ARGS=()
6363

6464
while (($#)); do
6565
case $1 in
6666
--hiveconf)
6767
ensure_arg_number $# 2
68-
THRIFT_SERVER_ARGS+=" $1"; shift
69-
THRIFT_SERVER_ARGS+=" $1"; shift
68+
THRIFT_SERVER_ARGS+=($1); shift
69+
THRIFT_SERVER_ARGS+=($1); shift
7070
;;
7171

7272
*)
73-
SUBMISSION_ARGS+=" $1"; shift
73+
SUBMISSION_ARGS+=($1); shift
7474
;;
7575
esac
7676
done
7777

78-
exec "$FWDIR"/bin/spark-submit --class $CLASS $SUBMISSION_ARGS spark-internal $THRIFT_SERVER_ARGS
78+
eval exec "$FWDIR"/bin/spark-submit --class $CLASS ${SUBMISSION_ARGS[*]} spark-internal ${THRIFT_SERVER_ARGS[*]}

0 commit comments

Comments
 (0)