Skip to content

Commit

Permalink
Using eval to retain quoted arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
liancheng committed Aug 6, 2014
1 parent aed523f commit 8493a9e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 17 deletions.
28 changes: 17 additions & 11 deletions bin/spark-sql
Original file line number Diff line number Diff line change
Expand Up @@ -58,31 +58,37 @@ if [[ "$@" = --help ]] || [[ "$@" = -h ]]; then
exit 0
fi

CLI_ARGS=""
SUBMISSION_ARGS=""
CLI_ARGS=()
SUBMISSION_ARGS=()

while (($#)); do
case $1 in
-d | --define | --database | -e | -f | -h | --hiveconf | --hivevar | -i | -p)
case $1 in
-d | --define | --database | -f | -h | --hiveconf | --hivevar | -i | -p)
ensure_arg_number $# 2
CLI_ARGS+=" $1"; shift
CLI_ARGS+=" $1"; shift
CLI_ARGS+=($1); shift
CLI_ARGS+=($1); shift
;;

-e)
ensure_arg_number $# 2
CLI_ARGS+=($1); shift
CLI_ARGS+=(\"$1\"); shift
;;

-s | --silent)
CLI_ARGS+=" $1"; shift
CLI_ARGS+=($1); shift
;;

-v | --verbose)
# Both SparkSubmit and SparkSQLCLIDriver recognizes -v | --verbose
CLI_ARGS+=" $1"
SUBMISSION_ARGS+=" $1"; shift
CLI_ARGS+=($1)
SUBMISSION_ARGS+=($1); shift
;;

*)
SUBMISSION_ARGS+=" $1"; shift
SUBMISSION_ARGS+=($1); shift
;;
esac
done

exec "$FWDIR"/bin/spark-submit --class $CLASS $SUBMISSION_ARGS spark-internal $CLI_ARGS
eval exec "$FWDIR"/bin/spark-submit --class $CLASS ${SUBMISSION_ARGS[*]} spark-internal ${CLI_ARGS[*]}
12 changes: 6 additions & 6 deletions sbin/start-thriftserver.sh
Original file line number Diff line number Diff line change
Expand Up @@ -58,21 +58,21 @@ if [[ "$@" = --help ]] || [[ "$@" = -h ]]; then
exit 0
fi

THRIFT_SERVER_ARGS=""
SUBMISSION_ARGS=""
THRIFT_SERVER_ARGS=()
SUBMISSION_ARGS=()

while (($#)); do
case $1 in
--hiveconf)
ensure_arg_number $# 2
THRIFT_SERVER_ARGS+=" $1"; shift
THRIFT_SERVER_ARGS+=" $1"; shift
THRIFT_SERVER_ARGS+=($1); shift
THRIFT_SERVER_ARGS+=($1); shift
;;

*)
SUBMISSION_ARGS+=" $1"; shift
SUBMISSION_ARGS+=($1); shift
;;
esac
done

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

0 comments on commit 8493a9e

Please sign in to comment.