From 9d23527663380d872494fecc4f1db72267799c30 Mon Sep 17 00:00:00 2001 From: Xiaobo Liu Date: Tue, 14 Oct 2025 23:48:24 +0800 Subject: [PATCH] util: Respect user-defined SHELL environment variable (#40181) Fix issue where Zed would unconditionally override user's custom shell with system default from passwd entry. Closes https://github.com/zed-industries/zed/issues/40171 Release Notes: - Fix issue where Zed would unconditionally override user's custom shell with system default from passwd entry. --------- Signed-off-by: Xiaobo Liu --- crates/util/src/util.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/util/src/util.rs b/crates/util/src/util.rs index c469ddcce3bd736088d9c97b03a3ba3f566d41b8..3f1205f96531a897ac67492c84bc2f7e949ab02a 100644 --- a/crates/util/src/util.rs +++ b/crates/util/src/util.rs @@ -279,7 +279,11 @@ fn load_shell_from_passwd() -> Result<()> { ); let shell = unsafe { std::ffi::CStr::from_ptr(entry.pw_shell).to_str().unwrap() }; - if env::var("SHELL").map_or(true, |shell_env| shell_env != shell) { + let should_set_shell = env::var("SHELL").map_or(true, |shell_env| { + shell_env != shell && !std::path::Path::new(&shell_env).exists() + }); + + if should_set_shell { log::info!( "updating SHELL environment variable to value from passwd entry: {:?}", shell,