Skip to content

Commit

Permalink
Give flamework
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Oct 23, 2024
1 parent f77afe0 commit 2a648ee
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/elements/word.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
mod brace_expansion;
mod tilde_expansion;
mod substitution;
mod path_expansion;
mod split;

use crate::{Feeder, ShellCore};
use crate::elements::subword;
Expand All @@ -20,7 +22,7 @@ impl Word {
let mut ws = vec![];
for w in brace_expansion::eval(&mut self.clone()) {
match w.tilde_and_dollar_expansion(core) {
Some(w) => ws.push(w),
Some(w) => ws.append( &mut w.split_and_path_expansion(core) ),
None => return None,
};
}
Expand All @@ -36,6 +38,14 @@ impl Word {
}
}

pub fn split_and_path_expansion(&self, core: &mut ShellCore) -> Vec<Word> {
let mut ans = vec![];
for mut w in split::eval(self, core) {
ans.append(&mut path_expansion::eval(&mut w) );
}
ans
}

fn make_args(words: &mut Vec<Word>) -> Vec<String> {
words.iter_mut()
.map(|w| w.make_unquoted_word())
Expand Down
8 changes: 8 additions & 0 deletions src/elements/word/path_expansion.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
//SPDX-FileCopyrightText: 2024 Ryuichi Ueda ryuichiueda@gmail.com
//SPDX-License-Identifier: BSD-3-Clause

use crate::elements::word::Word;

pub fn eval(word: &mut Word) -> Vec<Word> {
vec![word.clone()]
}
9 changes: 9 additions & 0 deletions src/elements/word/split.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
//SPDX-FileCopyrightText: 2024 Ryuichi Ueda <ryuichiueda@gmail.com>
//SPDX-License-Identifier: BSD-3-Clause

use crate::ShellCore;
use crate::elements::word::Word;

pub fn eval(word: &Word, _: &mut ShellCore) -> Vec<Word> {
vec![word.clone()]
}

0 comments on commit 2a648ee

Please sign in to comment.