summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorShunsuke Mie <sux2mfgj@gmail.com>2022-11-16 00:22:38 +0900
committerGitHub <noreply@github.com>2022-11-15 15:22:38 +0000
commit4aae81faf8c215351ec0f69714f67e36f8e154c7 (patch)
treee889ab13c4729d3a20b58b6a98c21bce7923a08f
parentc66a8c0629e8b80bf9b20f0288164dc701b03a24 (diff)
fix(pty): use /bin/sh when SHELL env variable is not found (#1769)
This commit fixes #1722. In some environment, the SHELL environemnt variable is not exists. It causes a panic that is reported as #1722. Use generic shell (/bin/sh) to prevent the panic. This is a same behavior as tmux. https://github.com/tmux/tmux/blob/master/spawn.c#L329-L331
-rw-r--r--zellij-server/src/pty.rs9
1 files changed, 8 insertions, 1 deletions
diff --git a/zellij-server/src/pty.rs b/zellij-server/src/pty.rs
index ebf72e89d..5034e7a67 100644
--- a/zellij-server/src/pty.rs
+++ b/zellij-server/src/pty.rs
@@ -433,9 +433,16 @@ impl Pty {
}
}
pub fn get_default_terminal(&self, cwd: Option<PathBuf>) -> TerminalAction {
+ let shell = PathBuf::from(env::var("SHELL").unwrap_or_else(|_| {
+ log::warn!("Cannot read SHELL env, falling back to use /bin/sh");
+ "/bin/sh".to_string()
+ }));
+ if !shell.exists() {
+ panic!("Cannot find shell {}", shell.display());
+ }
TerminalAction::RunCommand(RunCommand {
args: vec![],
- command: PathBuf::from(env::var("SHELL").expect("Could not find the SHELL variable")),
+ command: shell,
cwd, // note: this might also be filled by the calling function, eg. spawn_terminal
hold_on_close: false,
hold_on_start: false,