How to get exit status of spark-shell<<EOF <spark queries>EOF in bash script?

427 views Asked by At

I have part of shell script as below..

spark_data=spark-shell << EOF spark.sql(query) EOF

i need the exit status of the spark.sql query.. Can someone help on this..

Awaiting your reply Thanks

1

There are 1 answers

8
chepner On

Since the assignment is part of another command, the exit status of the assignment is the exit status of the command substitution.

$ foo=$(cat <<EOF
> hi
> there
> EOF
> exit 9)
$ echo $?
9
$ echo "$foo"
hi
there