diff --git a/kitty/launch_wrapper.py b/kitty/launch_wrapper.py index 72619ba1e..26b0b072c 100644 --- a/kitty/launch_wrapper.py +++ b/kitty/launch_wrapper.py @@ -120,24 +120,24 @@ def prefix_for_launch(req: LaunchRequest, argv: Sequence[str], cwd: str, env: Ma window_id = int(env.get('KITTY_WINDOW_ID', '0')) except ValueError: window_id = 0 - ctx = LaunchContext( - argv=tuple(argv), - cwd=cwd, - env=MappingProxyType(dict(env)), - is_default_shell=list(argv) == resolved_shell(get_options()), - window_id=window_id, - launch_type=req.launch_type, - source_window_id=req.source_window_id, - source_pid=source_pid_for(req.source_window_id), - user_vars=MappingProxyType(dict(req.user_vars)), - ) try: + ctx = LaunchContext( + argv=tuple(argv), + cwd=cwd, + env=MappingProxyType(dict(env)), + is_default_shell=list(argv) == resolved_shell(get_options()), + window_id=window_id, + launch_type=req.launch_type, + source_window_id=req.source_window_id, + source_pid=source_pid_for(req.source_window_id), + user_vars=MappingProxyType(dict(req.user_vars)), + ) ans = func(ctx) except Exception as e: import traceback traceback.print_exc() - log_error(f'The {FUNCTION_NAME}() function in {MODULE_NAME} failed with error: {e}, running the command without a wrapper') + log_error(f'Failed to apply {MODULE_NAME} with error: {e}, running the command without a wrapper') return () if ans is None: return () diff --git a/kitty_tests/child.py b/kitty_tests/child.py index 127b8f6b1..1c89c000d 100644 --- a/kitty_tests/child.py +++ b/kitty_tests/child.py @@ -534,3 +534,17 @@ read -r _ c, exe, argv = self._fork(launch_request=req, user_func=self._recording(empty)) self.ae(argv, ('/bin/prog', 'arg')) self.ae(len(errors), 4) + + def test_launch_wrapper_invalid_shell(self): + from kitty import launch_wrapper + + self.set_options({'shell': '"unterminated', 'shell_integration': frozenset({'disabled'})}) + req = launch_wrapper.LaunchRequest('tab') + with patch.object(launch_wrapper, 'log_error') as log_error: + c, exe, argv = self._fork(launch_request=req, user_func=self._recording(['/bin/wrapper'])) + self.ae(exe, '/bin/prog') + self.ae(argv, ('/bin/prog', 'arg')) + self.ae(c.kitty_wrappers, ()) + self.ae(self.contexts, []) + log_error.assert_called_once() + self.assertIn('Unterminated string', log_error.call_args.args[0])