fix(plugins): respect default shell when configured in the $SHELL env variable (#3296)

* fix(plugins): respect $SHELL alias for default shell

* style(fmt): rustfmt

* fix tests
This commit is contained in:
Aram Drevekenin 2024-04-24 15:39:54 +02:00 committed by GitHub
parent fca7a209d2
commit 5e587333b5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 22 additions and 19 deletions

View file

@ -1,6 +1,6 @@
--- ---
source: zellij-server/src/plugins/./unit/plugin_tests.rs source: zellij-server/src/plugins/./unit/plugin_tests.rs
assertion_line: 4246 assertion_line: 4390
expression: "format!(\"{:#?}\", new_tab_event)" expression: "format!(\"{:#?}\", new_tab_event)"
--- ---
Some( Some(
@ -8,7 +8,7 @@ Some(
Some( Some(
RunCommand( RunCommand(
RunCommand { RunCommand {
command: "", command: ".",
args: [], args: [],
cwd: Some( cwd: Some(
"/path/to/my/file.rs", "/path/to/my/file.rs",

View file

@ -1,6 +1,6 @@
--- ---
source: zellij-server/src/plugins/./unit/plugin_tests.rs source: zellij-server/src/plugins/./unit/plugin_tests.rs
assertion_line: 4169 assertion_line: 4312
expression: "format!(\"{:#?}\", new_tab_event)" expression: "format!(\"{:#?}\", new_tab_event)"
--- ---
Some( Some(
@ -8,7 +8,7 @@ Some(
Some( Some(
RunCommand( RunCommand(
RunCommand { RunCommand {
command: "", command: ".",
args: [], args: [],
cwd: Some( cwd: Some(
"/path/to/my/file.rs", "/path/to/my/file.rs",

View file

@ -515,11 +515,12 @@ fn open_file_in_place(env: &ForeignFunctionEnv, file_to_open: FileToOpen) {
fn open_terminal(env: &ForeignFunctionEnv, cwd: PathBuf) { fn open_terminal(env: &ForeignFunctionEnv, cwd: PathBuf) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name()); let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd); let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
.plugin_env TerminalAction::RunCommand(RunCommand {
.default_shell command: env.plugin_env.path_to_default_shell.clone(),
.clone() ..Default::default()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default())); })
});
default_shell.change_cwd(cwd); default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell { let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()), TerminalAction::RunCommand(run_command) => Some(run_command.into()),
@ -536,11 +537,12 @@ fn open_terminal_floating(
) { ) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name()); let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd); let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
.plugin_env TerminalAction::RunCommand(RunCommand {
.default_shell command: env.plugin_env.path_to_default_shell.clone(),
.clone() ..Default::default()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default())); })
});
default_shell.change_cwd(cwd); default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell { let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()), TerminalAction::RunCommand(run_command) => Some(run_command.into()),
@ -553,11 +555,12 @@ fn open_terminal_floating(
fn open_terminal_in_place(env: &ForeignFunctionEnv, cwd: PathBuf) { fn open_terminal_in_place(env: &ForeignFunctionEnv, cwd: PathBuf) {
let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name()); let error_msg = || format!("failed to open file in plugin {}", env.plugin_env.name());
let cwd = env.plugin_env.plugin_cwd.join(cwd); let cwd = env.plugin_env.plugin_cwd.join(cwd);
let mut default_shell = env let mut default_shell = env.plugin_env.default_shell.clone().unwrap_or_else(|| {
.plugin_env TerminalAction::RunCommand(RunCommand {
.default_shell command: env.plugin_env.path_to_default_shell.clone(),
.clone() ..Default::default()
.unwrap_or_else(|| TerminalAction::RunCommand(RunCommand::default())); })
});
default_shell.change_cwd(cwd); default_shell.change_cwd(cwd);
let run_command_action: Option<RunCommandAction> = match default_shell { let run_command_action: Option<RunCommandAction> = match default_shell {
TerminalAction::RunCommand(run_command) => Some(run_command.into()), TerminalAction::RunCommand(run_command) => Some(run_command.into()),