From d67d7cda39f5c3a84ee030778d69cdf08634a33c Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Sun, 9 Jan 2022 23:26:02 -0500 Subject: fix builtins wrapping builtins --- src/runner/builtins/command.rs | 29 +++-------------------------- src/runner/builtins/mod.rs | 6 +++--- 2 files changed, 6 insertions(+), 29 deletions(-) (limited to 'src/runner/builtins') diff --git a/src/runner/builtins/command.rs b/src/runner/builtins/command.rs index 2c1f755..7d84c8f 100644 --- a/src/runner/builtins/command.rs +++ b/src/runner/builtins/command.rs @@ -9,23 +9,7 @@ pub struct Command { } impl Command { - pub fn new(exe: crate::parse::Exe) -> Result { - if let Some(s) = exe.exe().to_str() { - if let Some(f) = super::BUILTINS.get(s) { - Ok(Self { - exe, - f, - cfg: Cfg::new(), - }) - } else { - Err(exe) - } - } else { - Err(exe) - } - } - - pub fn new_with_io( + pub fn new( exe: crate::parse::Exe, io: Io, ) -> Result { @@ -34,7 +18,7 @@ impl Command { Ok(Self { exe, f, - cfg: Cfg::new_with_io(io), + cfg: Cfg::new(io), }) } else { Err(exe) @@ -83,14 +67,7 @@ pub struct Cfg { } impl Cfg { - fn new() -> Self { - Self { - io: Io::new(), - pre_exec: None, - } - } - - fn new_with_io(io: Io) -> Self { + fn new(io: Io) -> Self { Self { io, pre_exec: None } } diff --git a/src/runner/builtins/mod.rs b/src/runner/builtins/mod.rs index 3ae02ea..07be59f 100644 --- a/src/runner/builtins/mod.rs +++ b/src/runner/builtins/mod.rs @@ -263,7 +263,7 @@ fn and( ) -> anyhow::Result { exe.shift(); if env.latest_status().success() { - let mut cmd = crate::runner::Command::new(exe); + let mut cmd = crate::runner::Command::new(exe, cfg.io().clone()); cfg.setup_command(&mut cmd); Ok(command::Child::new_wrapped(cmd.spawn(env)?)) } else { @@ -282,7 +282,7 @@ fn or( let status = *env.latest_status(); Ok(command::Child::new_fut(async move { status })) } else { - let mut cmd = crate::runner::Command::new(exe); + let mut cmd = crate::runner::Command::new(exe, cfg.io().clone()); cfg.setup_command(&mut cmd); Ok(command::Child::new_wrapped(cmd.spawn(env)?)) } @@ -305,7 +305,7 @@ fn builtin( cfg: command::Cfg, ) -> anyhow::Result { exe.shift(); - let mut cmd = crate::runner::Command::new_builtin(exe); + let mut cmd = crate::runner::Command::new_builtin(exe, cfg.io().clone()); cfg.setup_command(&mut cmd); Ok(command::Child::new_wrapped(cmd.spawn(env)?)) } -- cgit v1.2.3-54-g00ecf