1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #269 from ebfe/sum

sum: pass busybox tests
This commit is contained in:
Oly Mi 2014-06-18 14:46:56 +04:00
commit 360daca1aa

View file

@ -111,13 +111,16 @@ 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) {
let print_names = sysv || files.len() > 1;
for file in files.iter() {
let reader = match open(file.as_slice()) {
Ok(f) => f,
_ => crash!(1, "unable to open file")
};
@ -127,7 +130,12 @@ pub fn uumain(args: Vec<String>) -> int {
bsd_sum(reader)
};
if print_names {
println!("{} {} {}", sum, blocks, file);
} else {
println!("{} {}", sum, blocks);
}
}
0
}