From f99220f01553c6c9d36e1f4ce01c007f4d4d4cb5 Mon Sep 17 00:00:00 2001 From: Kirill Chibisov Date: Fri, 5 Jun 2020 01:10:31 +0300 Subject: Refactor Shell, Command, and Launcher to share impl --- alacritty_terminal/src/tty/unix.rs | 12 ++++++------ alacritty_terminal/src/tty/windows/mod.rs | 8 ++++---- 2 files changed, 10 insertions(+), 10 deletions(-) (limited to 'alacritty_terminal/src/tty') diff --git a/alacritty_terminal/src/tty/unix.rs b/alacritty_terminal/src/tty/unix.rs index 2db59519..2c2f4eee 100644 --- a/alacritty_terminal/src/tty/unix.rs +++ b/alacritty_terminal/src/tty/unix.rs @@ -14,7 +14,7 @@ // //! TTY related functionality. -use crate::config::{Config, Shell}; +use crate::config::{Config, Program}; use crate::event::OnResize; use crate::term::SizeInfo; use crate::tty::{ChildEvent, EventedPty, EventedReadWrite}; @@ -163,14 +163,14 @@ pub fn new(config: &Config, size: &SizeInfo, window_id: Option) -> let shell_name = pw.shell.rsplit('/').next().unwrap(); let argv = vec![String::from("-c"), format!("exec -a -{} {}", shell_name, pw.shell)]; - Shell::new_with_args("/bin/bash", argv) + Program::WithArgs { program: "/bin/bash".to_owned(), args: argv } } else { - Shell::new(pw.shell) + Program::Just(pw.shell.to_owned()) }; let shell = config.shell.as_ref().unwrap_or(&default_shell); - let mut builder = Command::new(&*shell.program); - for arg in &shell.args { + let mut builder = Command::new(&*shell.program()); + for arg in shell.args() { builder.arg(arg); } @@ -246,7 +246,7 @@ pub fn new(config: &Config, size: &SizeInfo, window_id: Option) -> pty.on_resize(size); pty }, - Err(err) => die!("Failed to spawn command '{}': {}", shell.program, err), + Err(err) => die!("Failed to spawn command '{}': {}", shell.program(), err), } } diff --git a/alacritty_terminal/src/tty/windows/mod.rs b/alacritty_terminal/src/tty/windows/mod.rs index 47b03d90..685e7849 100644 --- a/alacritty_terminal/src/tty/windows/mod.rs +++ b/alacritty_terminal/src/tty/windows/mod.rs @@ -18,7 +18,7 @@ use std::iter::once; use std::os::windows::ffi::OsStrExt; use std::sync::mpsc::TryRecvError; -use crate::config::{Config, Shell}; +use crate::config::{Config, Program}; use crate::event::OnResize; use crate::term::SizeInfo; use crate::tty::windows::child::ChildExitWatcher; @@ -197,11 +197,11 @@ impl OnResize for Pty { } fn cmdline(config: &Config) -> String { - let default_shell = Shell::new("powershell"); + let default_shell = Program::Just("powershell".to_owned()); let shell = config.shell.as_ref().unwrap_or(&default_shell); - once(shell.program.as_ref()) - .chain(shell.args.iter().map(|a| a.as_ref())) + once(shell.program().as_ref()) + .chain(shell.args().iter().map(|a| a.as_ref())) .collect::>() .join(" ") } -- cgit v1.2.3-54-g00ecf