I've just found this bug.
I think you also need to add `export` at [line 130](https://github.com/aarondav/spark/blob/6a0e34063f97da38fdaf1cb72a033dabcc4c9b04/bin/spark-shell#L130) for `-m` option or at [the last part](https://github.com/aarondav/spark/blob/6a0e34063f97da38fdaf1cb72a033dabcc4c9b04/bin/spark-shell#L150) of `resolve_spark_master` function.