From 57090aa2bf79acdc4520dd538c809e626204161b Mon Sep 17 00:00:00 2001 From: Ryuichi Ueda Date: Mon, 8 Jan 2024 20:52:52 +0900 Subject: [PATCH] Refactor --- src/elements/command/if.rs | 41 ++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/elements/command/if.rs b/src/elements/command/if.rs index b552745b..e0d629b9 100644 --- a/src/elements/command/if.rs +++ b/src/elements/command/if.rs @@ -45,33 +45,36 @@ impl IfCommand { } } - fn eat_script(word: &str, feeder: &mut Feeder, ans: &mut IfCommand, core: &mut ShellCore) -> bool { - let mut s = None; - if command::eat_inner_script(feeder, core, word, Self::end_words(word), &mut s) { - ans.text.push_str(word); - ans.text.push_str(&s.as_mut().unwrap().get_text()); - - match word { - "if" | "elif" => ans.if_elif_scripts.push(s.unwrap()), - "then" => ans.then_scripts.push(s.unwrap()), - "else" => ans.else_script = s, - _ => panic!("SUSH INTERNAL ERROR (if parse error)"), - }; + fn set_script(word: &str, ans: &mut IfCommand, script: Option