Modify the way the login shell is launched on macOS to reduce nesting

This commit is contained in:
Matthew Winter
2023-12-30 03:51:16 +11:00
parent 6532ff73a8
commit 5e3e76bcae

View File

@ -841,12 +841,6 @@ const Subprocess = struct {
break :hush if (dir.access(".hushlogin", .{})) true else |_| false; break :hush if (dir.access(".hushlogin", .{})) true else |_| false;
} else false; } else false;
const cmd = try std.fmt.allocPrint(
alloc,
"exec -l {s}",
.{opts.full_config.command orelse default_path},
);
// The reason for executing login this way is unclear. This // The reason for executing login this way is unclear. This
// comment will attempt to explain but prepare for a truly // comment will attempt to explain but prepare for a truly
// unhinged reality. // unhinged reality.
@ -892,15 +886,11 @@ const Subprocess = struct {
try args.append("-flp"); try args.append("-flp");
try args.append(username); try args.append(username);
// We execute zsh with "-d -f" so that it doesn't load any // We execute `env` to run the command (aka shell) in a
// local zshrc files so that (1) our shell integration doesn't // modified environment and not use another shell interpreter
// break and (2) user configuration doesn't mess this process // to launch the shell environment.
// up. try args.append("/usr/bin/env");
try args.append("/bin/zsh"); try args.append(opts.full_config.command orelse default_path);
try args.append("-d");
try args.append("-f");
try args.append("-c");
try args.append(cmd);
break :args try args.toOwnedSlice(); break :args try args.toOwnedSlice();
} }