From 98350f52df1d783886313682a5eada8a729cbaed Mon Sep 17 00:00:00 2001 From: Ellie Huxtable Date: Fri, 19 Apr 2024 09:58:25 +0100 Subject: [PATCH] fix: support not-mac for default shell (#1960) --- crates/atuin-common/src/shell.rs | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/crates/atuin-common/src/shell.rs b/crates/atuin-common/src/shell.rs index 42e32f72..afdccea7 100644 --- a/crates/atuin-common/src/shell.rs +++ b/crates/atuin-common/src/shell.rs @@ -67,26 +67,25 @@ impl Shell { // TODO: Support Linux // I'm pretty sure we can use /etc/passwd there, though there will probably be some issues - if sys.contains("darwin") { + let path = if sys.contains("darwin") { // This works in my testing so far - let path = Shell::Sh.run_interactive([ + Shell::Sh.run_interactive([ "dscl localhost -read \"/Local/Default/Users/$USER\" shell | awk '{print $2}'", - ])?; - - let path = Path::new(path.trim()); - - let shell = path.file_name(); - - if shell.is_none() { - return Err(ShellError::NotSupported); - } - - Ok(Shell::from_string( - shell.unwrap().to_string_lossy().to_string(), - )) + ])? } else { - Err(ShellError::NotSupported) + Shell::Sh.run_interactive(["getent passwd $LOGNAME | cut -d: -f7"])? + }; + + let path = Path::new(path.trim()); + let shell = path.file_name(); + + if shell.is_none() { + return Err(ShellError::NotSupported); } + + Ok(Shell::from_string( + shell.unwrap().to_string_lossy().to_string(), + )) } pub fn from_string(name: String) -> Shell {