core: disable shell integration for initial-command

When an initial command is provided (either via -e or from explicit
configuration), disable shell integration. The assumption is that this
command is rarely a shell, and injecting our shell integration into this
command's environment (e.g. when 'shell-integration' is forced) can
cause unexpected behavior.
This commit is contained in:
Jon Parise
2024-12-14 19:36:58 -05:00
parent fba10a442c
commit 533fdeddd5

View File

@ -507,11 +507,18 @@ pub fn init(
.config_conditional_state = app.config_conditional_state,
};
// The command we're going to execute
const command: ?[]const u8 = if (app.first)
config.@"initial-command" orelse config.command
else
config.command;
// The command we're going to execute is either 'initial-command'
// (from -e or explicit configuration) or 'command' (our shell or
// explicit configuration). Shell integration is disabled when
// we're using 'initial-command'.
const command: ?[]const u8, const shell_integration: configpkg.Config.ShellIntegration = config: {
if (app.first) {
if (config.@"initial-command") |initial_command| {
break :config .{ initial_command, .none };
}
}
break :config .{ config.command, config.@"shell-integration" };
};
// Start our IO implementation
// This separate block ({}) is important because our errdefers must
@ -520,7 +527,7 @@ pub fn init(
// Initialize our IO backend
var io_exec = try termio.Exec.init(alloc, .{
.command = command,
.shell_integration = config.@"shell-integration",
.shell_integration = shell_integration,
.shell_integration_features = config.@"shell-integration-features",
.working_directory = config.@"working-directory",
.resources_dir = global_state.resources_dir,