mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 12:07:46 +00:00
sum: handle multiple file args
This commit is contained in:
parent
ee92573584
commit
156577ec40
1 changed files with 15 additions and 13 deletions
10
sum/sum.rs
10
sum/sum.rs
|
@ -111,13 +111,14 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
|
||||
let sysv = matches.opt_present("sysv");
|
||||
|
||||
let file = if matches.free.is_empty() {
|
||||
"-"
|
||||
let files = if matches.free.is_empty() {
|
||||
Vec::from_elem(1, "-".to_string())
|
||||
} else {
|
||||
matches.free.get(0).as_slice()
|
||||
matches.free
|
||||
};
|
||||
|
||||
let reader = match open(file) {
|
||||
for file in files.iter() {
|
||||
let reader = match open(file.as_slice()) {
|
||||
Ok(f) => f,
|
||||
_ => crash!(1, "unable to open file")
|
||||
};
|
||||
|
@ -128,6 +129,7 @@ pub fn uumain(args: Vec<String>) -> int {
|
|||
};
|
||||
|
||||
println!("{} {}", sum, blocks);
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue