From a69ec2127ed877c8607aef353a5591b6d05dfcfb Mon Sep 17 00:00:00 2001 From: Mitchell Hashimoto Date: Fri, 29 Dec 2023 15:41:11 -0800 Subject: [PATCH] termio/exec: use bash instead of zsh for shell launching --- src/termio/Exec.zig | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/termio/Exec.zig b/src/termio/Exec.zig index 2624c6e52..8e8449559 100644 --- a/src/termio/Exec.zig +++ b/src/termio/Exec.zig @@ -878,10 +878,15 @@ const Subprocess = struct { // "-q" flag to login(1). // // So to get all the behaviors we want, we specify "-l" but - // execute "zsh" (which is built-in to macOS). We then use - // the zsh builtin "exec" to replace the process with a login + // execute "bash" (which is built-in to macOS). We then use + // the bash builtin "exec" to replace the process with a login // shell ("-l" on exec) with the command we really want. // + // We use "bash" instead of other shells that ship with macOS + // because as of macOS Sonoma, we found with a microbenchmark + // that bash can `exec` into the desired command ~2x faster + // than zsh. + // // To figure out a lot of this logic I read the login.c // source code in the OSS distribution Apple provides for // macOS. @@ -890,8 +895,15 @@ const Subprocess = struct { try args.append("/usr/bin/login"); if (hush) try args.append("-q"); try args.append("-flp"); + + // We execute bash with "--noprofile --norc" so that it doesn't + // load startup files so that (1) our shell integration doesn't + // break and (2) user configuration doesn't mess this process + // up. try args.append(username); - try args.append("/bin/sh"); + try args.append("/bin/bash"); + try args.append("--noprofile"); + try args.append("--norc"); try args.append("-c"); try args.append(cmd); break :args try args.toOwnedSlice();