mirror of
https://github.com/ghostty-org/ghostty.git
synced 2025-07-16 08:46:08 +03:00
termio: fix "forced" shell integration
When a shell is forced, we would supply its /-prefixed executable name to mimic a path location. The rest of the integration detection logic assumes just a base executable name. Fix the forced names accordingly. Also add a unit test for this "force shell" behavior.
This commit is contained in:
@ -16,4 +16,6 @@ pub const Impl = Exec;
|
|||||||
|
|
||||||
test {
|
test {
|
||||||
@import("std").testing.refAllDecls(@This());
|
@import("std").testing.refAllDecls(@This());
|
||||||
|
|
||||||
|
_ = @import("termio/shell_integration.zig");
|
||||||
}
|
}
|
||||||
|
@ -29,8 +29,8 @@ pub fn setup(
|
|||||||
features: config.ShellIntegrationFeatures,
|
features: config.ShellIntegrationFeatures,
|
||||||
) !?Shell {
|
) !?Shell {
|
||||||
const exe = if (force_shell) |shell| switch (shell) {
|
const exe = if (force_shell) |shell| switch (shell) {
|
||||||
.fish => "/fish",
|
.fish => "fish",
|
||||||
.zsh => "/zsh",
|
.zsh => "zsh",
|
||||||
} else std.fs.path.basename(command_path);
|
} else std.fs.path.basename(command_path);
|
||||||
|
|
||||||
const shell: Shell = shell: {
|
const shell: Shell = shell: {
|
||||||
@ -123,3 +123,16 @@ fn setupZsh(
|
|||||||
);
|
);
|
||||||
try env.put("ZDOTDIR", integ_dir);
|
try env.put("ZDOTDIR", integ_dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
test "force shell" {
|
||||||
|
const testing = std.testing;
|
||||||
|
const alloc = testing.allocator;
|
||||||
|
|
||||||
|
var env = EnvMap.init(alloc);
|
||||||
|
defer env.deinit();
|
||||||
|
|
||||||
|
inline for (@typeInfo(Shell).Enum.fields) |field| {
|
||||||
|
const shell = @field(Shell, field.name);
|
||||||
|
try testing.expectEqual(shell, setup(alloc, ".", "sh", &env, shell, .{}));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user