Remote control launch: Fix --env not implemented when using --cwd=current with the SSH kitten

Fixes #6438
This commit is contained in:
Kovid Goyal
2023-07-11 07:06:48 +05:30
parent 72f283e7f7
commit a1e5b72ca5
4 changed files with 26 additions and 6 deletions

View File

@@ -206,7 +206,7 @@ class Child:
self.argv = list(argv)
if cwd_from:
try:
cwd = cwd_from.modify_argv_for_launch_with_cwd(self.argv) or cwd
cwd = cwd_from.modify_argv_for_launch_with_cwd(self.argv, env) or cwd
except Exception as err:
log_error(f'Failed to read cwd of {cwd_from} with error: {err}')
else:

View File

@@ -144,7 +144,7 @@ class CwdRequest:
return window.get_cwd_of_root_child() or ''
return window.get_cwd_of_child(oldest=self.request_type is CwdRequestType.oldest) or ''
def modify_argv_for_launch_with_cwd(self, argv: List[str]) -> str:
def modify_argv_for_launch_with_cwd(self, argv: List[str], env: Optional[Dict[str, str]]=None) -> str:
window = self.window
if not window:
return ''
@@ -154,12 +154,14 @@ class CwdRequest:
if ssh_kitten_cmdline:
run_shell = argv[0] == resolved_shell(get_options())[0]
server_args = [] if run_shell else list(argv)
from kittens.ssh.utils import set_cwd_in_cmdline, set_server_args_in_cmdline
from kittens.ssh.utils import set_cwd_in_cmdline, set_env_in_cmdline, set_server_args_in_cmdline
argv[:] = ssh_kitten_cmdline
if argv and argv[0] == 'kitten':
argv[0] = kitten_exe()
set_cwd_in_cmdline(reported_cwd, argv)
set_server_args_in_cmdline(server_args, argv, allocate_tty=not run_shell)
if env is not None:
set_env_in_cmdline(env, argv, clone=False)
return ''
if not window.child_is_remote and (self.request_type is CwdRequestType.last_reported or window.at_prompt):
return reported_cwd