Skip to content

Commit

Permalink
Fix
Browse files Browse the repository at this point in the history
  • Loading branch information
ryuichiueda committed Jul 28, 2024
1 parent 37f8cf5 commit 59e6998
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
17 changes: 8 additions & 9 deletions src/elements/word/brace_expansion.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,13 +142,7 @@ fn expand_comma_brace(subwords: &Vec<Box<dyn Subword>>, delimiters: &Vec<usize>)
invalidate_brace(&mut right);

let sws = comma_brace_to_subwords(subwords, delimiters);
let mut ws = subword_sets_to_words(&sws, &left, &right);

let mut ans = vec![];
for w in ws.iter_mut() {
ans.append(&mut eval(w));
}
ans
subword_sets_to_words(&sws, &left, &right)
}

fn expand_range_brace(subwords: &mut Vec<Box<dyn Subword>>, delimiters: &Vec<usize>, operand_num: usize) -> Vec<Word> {
Expand Down Expand Up @@ -231,12 +225,17 @@ fn gen_chars(start: &str, end: &str, skip: usize) -> Vec<Box<dyn Subword>> {

fn subword_sets_to_words(series: &Vec<Vec<Box<dyn Subword>>>,
left: &[Box<dyn Subword>], right: &[Box<dyn Subword>]) -> Vec<Word> {
let mut ans = vec![];
let mut ws = vec![];
for sws in series {
let mut w = Word::new();
w.subwords = [ left, sws, right ].concat();
w.text = w.subwords.iter().map(|s| s.get_text()).collect();
ans.push(w);
ws.push(w);
}

let mut ans = vec![];
for w in ws.iter_mut() {
ans.append(&mut eval(w));
}
ans
}
Expand Down
3 changes: 3 additions & 0 deletions test/test.bash
Original file line number Diff line number Diff line change
Expand Up @@ -908,6 +908,9 @@ res=$($com <<< 'echo {0..3..0}')
res=$($com <<< 'echo {0..3.0}')
[ "$res" == "{0..3.0}" ] || err $LINENO

res=$($com <<< 'echo {1..2}{1..2}')
[ "$res" == "11 12 21 22" ] || err $LINENO

# escaping

res=$($com <<< "echo a\ \ \ a")
Expand Down

0 comments on commit 59e6998

Please sign in to comment.