diff --git a/src/elements/word/brace_expansion.rs b/src/elements/word/brace_expansion.rs index 2e65bcba..2f0ee178 100644 --- a/src/elements/word/brace_expansion.rs +++ b/src/elements/word/brace_expansion.rs @@ -142,13 +142,7 @@ fn expand_comma_brace(subwords: &Vec>, delimiters: &Vec) 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>, delimiters: &Vec, operand_num: usize) -> Vec { @@ -231,12 +225,17 @@ fn gen_chars(start: &str, end: &str, skip: usize) -> Vec> { fn subword_sets_to_words(series: &Vec>>, left: &[Box], right: &[Box]) -> Vec { - 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 } diff --git a/test/test.bash b/test/test.bash index 564ea28f..1029bb99 100755 --- a/test/test.bash +++ b/test/test.bash @@ -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")