mirror of
https://github.com/kovidgoyal/kitty
synced 2026-06-08 22:28:24 +02:00
kitten @ ls: Return environ of foreground process
This is needed on macOS where we now run the shell via login and we aren't allowed to read the environ of login because its setuid. Fixes #6749
This commit is contained in:
@@ -78,6 +78,8 @@ Detailed list of changes
|
||||
|
||||
- Render Private Use Unicode symbols using two cells if the second cell contains a non-breaking space as well as a normal space
|
||||
|
||||
- kitten @ ls: Return the environment of the foreground process instead of the initial child process (:iss:`6749`)
|
||||
|
||||
|
||||
0.30.1 [2023-10-05]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
@@ -214,10 +214,11 @@ class Child:
|
||||
self.cwd = os.path.abspath(cwd)
|
||||
self.stdin = stdin
|
||||
self.env = env or {}
|
||||
self.final_env:Dict[str, str] = {}
|
||||
self.is_default_shell = bool(self.argv and self.argv[0] == shell_path)
|
||||
self.should_run_via_run_shell_kitten = is_macos and self.is_default_shell
|
||||
|
||||
def final_env(self) -> Dict[str, str]:
|
||||
def get_final_env(self) -> Dict[str, str]:
|
||||
from kitty.options.utils import DELETE_ENV_VAR
|
||||
env = default_env().copy()
|
||||
opts = fast_data_types.get_options()
|
||||
@@ -273,8 +274,7 @@ class Child:
|
||||
os.set_inheritable(stdin_read_fd, True)
|
||||
else:
|
||||
stdin_read_fd = stdin_write_fd = -1
|
||||
final_env = self.final_env()
|
||||
env = tuple(f'{k}={v}' for k, v in final_env.items())
|
||||
self.final_env = self.get_final_env()
|
||||
argv = list(self.argv)
|
||||
cwd = self.cwd
|
||||
if self.should_run_via_run_shell_kitten:
|
||||
@@ -311,6 +311,7 @@ class Child:
|
||||
argv = ['/usr/bin/login', '-f', '-l', '-p', user] + argv
|
||||
self.final_exe = which(argv[0]) or argv[0]
|
||||
self.final_argv0 = argv[0]
|
||||
env = tuple(f'{k}={v}' for k, v in self.final_env.items())
|
||||
pid = fast_data_types.spawn(
|
||||
self.final_exe, cwd, tuple(argv), env, master, slave, stdin_read_fd, stdin_write_fd,
|
||||
ready_read_fd, ready_write_fd, tuple(handled_signals), kitten_exe(), opts.forward_stdio)
|
||||
|
||||
@@ -654,7 +654,7 @@ class Window:
|
||||
'pid': self.child.pid,
|
||||
'cwd': self.child.current_cwd or self.child.cwd,
|
||||
'cmdline': self.child.cmdline,
|
||||
'env': self.child.environ,
|
||||
'env': self.child.foreground_environ or self.child.environ or self.child.final_env,
|
||||
'foreground_processes': self.child.foreground_processes,
|
||||
'is_self': is_self,
|
||||
'at_prompt': self.at_prompt,
|
||||
|
||||
Reference in New Issue
Block a user