Skip to content

Commit

Permalink
Implement grep with pipe
Browse files Browse the repository at this point in the history
Signed-off-by: Federico Guerinoni <guerinoni.federico@gmail.com>
  • Loading branch information
guerinoni committed May 4, 2021
1 parent 70a6811 commit bc6d166
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ pub fn grep(c: Config) -> Result<Vec<String>, &'static str> {
io::stdin().read_to_string(&mut buffer).unwrap_or_default();
}

if c.filenames.len() == 1 && c.filenames[0] == "-" {
if c.filenames.is_empty() || c.filenames.len() == 1 && c.filenames[0] == "-" {
let stdin = io::stdin();
for line in stdin.lock().lines() {
let item = line.unwrap_or_default();
Expand Down

0 comments on commit bc6d166

Please sign in to comment.