diff --git a/examples/glob.ion b/examples/glob.ion index 10497d63fde1f86470fac7d60610b97d1fdf2808..ff060ea4fa4b3263c6148b2adc01d8ec9964ae2a 100644 --- a/examples/glob.ion +++ b/examples/glob.ion @@ -6,3 +6,11 @@ echo Cargo.* echo Cargo?toml echo Cargo.[tqr]oml echo examples/[ef]*.ion +mkdir glob_test +touch glob_test/{one,two,three} +cd glob_test +echo * +echo *[wh]* +echo [t]* +cd .. +rm glob_test -R diff --git a/examples/glob.out b/examples/glob.out index 77ac60852a58b5cfc63b9937076a1ca12996a8a0..5f262d264174d14cc172ef3ff021976ccdcb75fd 100644 --- a/examples/glob.out +++ b/examples/glob.out @@ -6,3 +6,6 @@ Cargo.lock Cargo.toml Cargo.toml Cargo.toml examples/else_if.ion examples/fail.ion examples/fibonacci.ion examples/fn.ion examples/for.ion +one three two +three two +three two diff --git a/src/parser/shell_expand/mod.rs b/src/parser/shell_expand/mod.rs index bb179b6cb5e5166e10e154d80b8f91929086c94c..5a04421fd07e532e063b380bd715321bb11105b4 100644 --- a/src/parser/shell_expand/mod.rs +++ b/src/parser/shell_expand/mod.rs @@ -254,7 +254,6 @@ pub fn expand_tokens<'a>(token_buffer: &[WordToken], expand_func: &'a ExpanderFu slice_string(&mut output, &expanded, index); }, WordToken::Normal(text,true) => { - //if this is a normal string that can be globbed, do it! let globbed = glob(text); if let Ok(var)=globbed{ for path in var.filter_map(Result::ok) { @@ -431,7 +430,6 @@ pub fn expand_tokens<'a>(token_buffer: &[WordToken], expand_func: &'a ExpanderFu output.push_str(text); }, WordToken::Normal(text,true) => { - //if this is a normal string that can be globbed, do it! let globbed = glob(text); if let Ok(var)=globbed{ is_glob=true; diff --git a/src/parser/shell_expand/words.rs b/src/parser/shell_expand/words.rs index 3f44c90c8f9d61202473abee36573b5c7707f643..58a8e90b09492b780331d0666db664977898266d 100644 --- a/src/parser/shell_expand/words.rs +++ b/src/parser/shell_expand/words.rs @@ -814,7 +814,6 @@ impl<'a> Iterator for WordIterator<'a> { let mut start = self.read; let mut glob = false; loop { - if let Some(character) = iterator.next() { match character { _ if self.flags & BACKSL != 0 => { @@ -905,10 +904,10 @@ impl<'a> Iterator for WordIterator<'a> { } } }, - b'*'|b'?' => { - // if a word is not special, make sure you return the globbed variant at the end - self.read+=1; - glob=true; //warning is incorrect it does get read + b'*' | b'?' => { + self.read += 1; + glob = true; + break }, _ => { self.read += 1; break }, } @@ -961,9 +960,8 @@ impl<'a> Iterator for WordIterator<'a> { } }, b'*'|b'?' if self.flags & SQUOTE == 0 => { - // if a word is not special, make sure you return the globbed variant at the end self.read += 1; - glob = true; //warning is incorrect it does get read + glob = true; }, _ => (), } @@ -973,7 +971,6 @@ impl<'a> Iterator for WordIterator<'a> { if start == self.read { None } else { - //println!("Normal exit"); Some(WordToken::Normal(&self.data[start..],glob)) } }