suppress Windows SHELL env error message - SPARK-53149 #51879
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
This PR suppresses an error message when running in a Windows SHELL environment
bash.exesession. It should not affect the execution path or behavior on Windows or any other OS.This is a minor change that should have no effect except when running in Windows SHELL environments.
Specifically, it should have no effect in normal usage in these environments:
The last part of script
bin/load-spark-env.shtests for whether running in foreground or background by callingps -o stat=and checking output for+. The purpose is to configure SPARK_BEELINE_OPTS for non-interactive environments if running in the background and not reading from a pipe. See SPARK-53149.This code causes Windows shell environments to print an error message to
stdout, due to a less capableps.exetool without support for theps -o stat= -p $$expression.AFAIK, there is no equivalent expression in any of these environments (MSYS2, cygwin64, Git-for-Windows). However, the error message can be suppressed by redirecting
stderrto /dev/null, reducing the negative impact.What changes were proposed in this pull request?
Currently, the last section of
bin/load-spark-env.shlooks like this:This PR redirects STDERR to
/dev/null, hiding the error message.Does this PR introduce any user-facing change?
One possible side-effect: If running in
Ubuntuor WindowsWSL/Ubuntuand theprocpspackage has not been installed, this has the effect of suppressing the error messagebash: ps: command not found. The same effect is possible on other systems if not properly configured with required packages.This is not an issue on
macOSbecausepsis included by default.There doesn't appear to be a way to reliably detect whether running in the foreground or background in a Windows SHELL environment, so the execution path is to always append to
SPARK_BEELINE_OPTSexcept when stdin is a pipe. This has the effect of disabling command line editing and other niceties for Windows SHELL clients, but does provide support non-interactive clients. In any event, this is the current behavior for those clients, and this PR doesn't change that, but it seems like a reasonable if not ideal default behavior.Why are the changes needed?
Because the error message indicates an unsupported feature in the SHELL environments (rather than a fixable error), it is misleading and unnecessary.
How was this patch tested?
Manualy verified the functional equivalence of the old and new conditional expressions, in each of the following environments:
The manual test was based on running the following test script in each environment. No error messages were produced.
Was this patch authored or co-authored using generative AI tooling?
No