Skip to main content

Module login_shell

Module login_shell 

Source
Expand description

The user’s login-shell PATH and selected environment values, for an app launched from the desktop (Finder, the Dock, a launch agent) that inherits only the session’s minimal environment. Unix only: on Windows every function returns nothing and runs nothing.

The shell is $SHELL when it is an absolute, existing file, else /bin/zsh, else /bin/sh. It runs as shell -lic <script> (login and interactive, so the profile files are read) under run with stdin closed, a hard deadline (the whole tree is killed at the deadline, so a profile that waits for a terminal cannot hang the caller) and a capped output. A timeout, a failure to start, truncated output, or a missing marker returns nothing.

Environment values are secrets. They are returned to the caller only, never printed, logged or placed on a command line (the names are checked to be plain identifiers before they go into the script).

Functions§

env_values
The login shell’s values of the named environment variables, as (name, value) pairs for the names that are set and non-empty there. Names that are not plain identifiers are skipped, and nothing is returned when the shell cannot answer within timeout. The values are secrets: the caller must not log them.
path
The login shell’s PATH, or None when it cannot be read within timeout.