diff --git a/src/elements/command/simple.rs b/src/elements/command/simple.rs index e95863ca..3e79a7dd 100644 --- a/src/elements/command/simple.rs +++ b/src/elements/command/simple.rs @@ -30,12 +30,12 @@ pub struct SimpleCommand { impl Command for SimpleCommand { fn exec(&mut self, core: &mut ShellCore, pipe: &mut Pipe) -> Option { - if self.words.len() == 0 { - return None; - } + self.args = self.words.iter() + .filter(|w| w.text != "") + .map(|w| w.text.clone()).collect(); - for a in &mut self.words { - self.args.extend(a.get_args()); + if self.args.len() == 0 { + return None; } if self.force_fork diff --git a/src/elements/subword.rs b/src/elements/subword.rs index a9b3fe3f..f360b2a9 100644 --- a/src/elements/subword.rs +++ b/src/elements/subword.rs @@ -18,7 +18,6 @@ impl Debug for dyn Subword { pub trait Subword { fn get_text(&self) -> String; - fn eval(&mut self) -> Vec>; } pub fn parse(feeder: &mut Feeder, core: &mut ShellCore) -> Option> { diff --git a/src/elements/subword/brace.rs b/src/elements/subword/brace.rs index c4f6c14a..95ad4713 100644 --- a/src/elements/subword/brace.rs +++ b/src/elements/subword/brace.rs @@ -13,7 +13,6 @@ pub struct BraceSubword { impl Subword for BraceSubword { fn get_text(&self) -> String { self.text.clone() } - fn eval(&mut self) -> Vec> { vec![vec![self.text.clone()]] } } impl BraceSubword { diff --git a/src/elements/subword/unquoted.rs b/src/elements/subword/unquoted.rs index 4a86be7d..e4e91bcc 100644 --- a/src/elements/subword/unquoted.rs +++ b/src/elements/subword/unquoted.rs @@ -11,7 +11,6 @@ pub struct UnquotedSubword { impl Subword for UnquotedSubword { fn get_text(&self) -> String { self.text.clone() } - fn eval(&mut self) -> Vec> { vec![vec![self.text.clone()]] } } impl UnquotedSubword { diff --git a/src/elements/word.rs b/src/elements/word.rs index 5704917c..bca0153e 100644 --- a/src/elements/word.rs +++ b/src/elements/word.rs @@ -12,17 +12,13 @@ pub struct Word { } impl Word { - fn new() -> Word { + pub fn new() -> Word { Word { text: String::new(), subwords: vec![], } } - pub fn get_args(&mut self) -> Vec { - vec![self.text.clone()] - } - pub fn parse(feeder: &mut Feeder, core: &mut ShellCore) -> Option { let mut ans = Word::new(); while let Some(sw) = subword::parse(feeder, core) {