use super::expression::Expression; use super::shell::*; use std::fmt::Write; use std::marker::PhantomData; #[derive(Debug)] pub(crate) struct SubShell> { _s: PhantomData, expression: Exp, } impl> SubShell { pub(crate) fn new(expression: Exp) -> Self { Self { _s: PhantomData, expression, } } } impl> Expression for SubShell { fn write_shell(&self, writer: &mut impl Write) -> std::fmt::Result { let mut s = String::new(); self.expression.write_shell(&mut s)?; write!(writer, r#"echo {} | zsh"#, Zsh::shell_escape(&s)) } } impl> Expression for SubShell { fn write_shell(&self, writer: &mut impl Write) -> std::fmt::Result { let mut s = String::new(); self.expression.write_shell(&mut s)?; write!(writer, r#"echo {} | bash"#, Bash::shell_escape(&s)) } } impl> Expression for SubShell { fn write_shell(&self, writer: &mut impl Write) -> std::fmt::Result { let mut s = String::new(); self.expression.write_shell(&mut s)?; write!(writer, r#"fish -c {}"#, Fish::shell_escape(&s)) } } impl> Expression for SubShell { fn write_shell(&self, writer: &mut impl Write) -> std::fmt::Result { let mut s = String::new(); self.expression.write_shell(&mut s)?; write!( writer, r#"echo {} | powershell -NoProfile"#, PowerShell::shell_escape(&s) ) } }