Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[macOS] Add support for loading shell environment from UI apps. #81266

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

bruvzg
Copy link
Member

@bruvzg bruvzg commented Sep 3, 2023

Adds OS::load_shell_environment method to load zsh and copy environment variables to the macOS GUI app environment.

OS::load_shell_environment is automatically used by the editor, and can be used manually from any other non-sandboxed project.

See #81240

Fixes #96409
Fixes #96596

Comment on lines +565 to +647
<method name="load_shell_environment" qualifiers="const">
<return type="void" />
<description>
Loads the default shell and copies environment variables set by the shell startup scripts to the app environment.
[b]Note:[/b] This method is implemented on macOS for non-sandboxed applications only.
</description>
</method>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's macOS specific, is there really much need for exposing it? Sounds more like a Godot editor implementation detail than a generic API users would make use of.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be useful for custom tools that are running external executables or configurable with environment variables, but still use GUI (and app bundle).

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we always call this method on startup (not just in the editor)? Is there a downside to always calling it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only negative impact is likely start-up time. Also running a shell on every start might look suspicious.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then, if we don't want to expose the method maybe we can expose a project setting to determine whether to call the method at startup or not.

Copy link
Member Author

@bruvzg bruvzg Sep 1, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess project setting OK as well, not sure what's better. We have plenty of OS methods that are useful only on a specific platform, or work completely differently (sandbox and permission related stuff, get_cmdline_platform_args).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
5 participants