1fanwang opened a new pull request, #55817: URL: https://github.com/apache/spark/pull/55817
### What changes were proposed in this pull request? `bin/find-spark-home` is documented as `# Should be included using "source" directive`, but its `SPARK_HOME`-already-set short-circuit calls `exit 0`. When the script is sourced, that terminates the caller's shell. This PR replaces `exit 0` with `return 0 2>/dev/null || exit 0` so the script behaves correctly when sourced (the documented path) and still works if executed directly. A pyspark unit test (`test_find_spark_home_script_sourceable`) sources the script twice from a subshell and asserts a marker prints after — the test fails on master and passes with this change. ### Why are the changes needed? `bin/find-spark-home` is sourced by `bin/load-spark-env.sh` and by user shell setup. As reported on SPARK-54434, if a user accidentally sources `bin/find-spark-home` twice in the same shell, the second invocation hits the short-circuit and `exit 0` closes the interactive shell session. Reproducer: ```bash export SPARK_HOME=/some/value source $SPARK_HOME/bin/find-spark-home # ok source $SPARK_HOME/bin/find-spark-home # shell terminates ``` ### Does this PR introduce _any_ user-facing change? No. Users who source `bin/find-spark-home` no longer lose their shell on the short-circuit path; users who execute it directly see no behavior change. ### How was this patch tested? Added `pyspark.tests.test_util.UtilTests.test_find_spark_home_script_sourceable`, which sources the script twice from a bash subprocess and asserts a marker prints after the second source. The test fails on `master` (the marker is never emitted because `exit 0` terminates the subshell) and passes with this change. ### Was this patch authored or co-authored using generative AI tooling? No -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
