mirror of
https://github.com/uutils/coreutils.git
synced 2025-07-08 05:54:59 +00:00
sum: fix output when using BSD sum algo (-r)
This commit is contained in:
parent
6a9660f9f6
commit
747bc2513e
4 changed files with 8 additions and 11 deletions
|
@ -116,11 +116,8 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let sysv = matches.get_flag(options::SYSTEM_V_COMPATIBLE);
|
let sysv = matches.get_flag(options::SYSTEM_V_COMPATIBLE);
|
||||||
|
|
||||||
let print_names = if sysv {
|
let print_names = files.len() > 1 || files[0] != "-";
|
||||||
files.len() > 1 || files[0] != "-"
|
let width = if sysv { 1 } else { 5 };
|
||||||
} else {
|
|
||||||
files.len() > 1
|
|
||||||
};
|
|
||||||
|
|
||||||
for file in &files {
|
for file in &files {
|
||||||
let reader = match open(file) {
|
let reader = match open(file) {
|
||||||
|
@ -137,9 +134,9 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
};
|
};
|
||||||
|
|
||||||
if print_names {
|
if print_names {
|
||||||
println!("{} {} {}", sum, blocks, file);
|
println!("{:0width$} {:width$} {}", sum, blocks, file);
|
||||||
} else {
|
} else {
|
||||||
println!("{} {}", sum, blocks);
|
println!("{:0width$} {:width$}", sum, blocks);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
8109 1 lorem_ipsum.txt
|
08109 1 lorem_ipsum.txt
|
||||||
1814 1 alice_in_wonderland.txt
|
01814 1 alice_in_wonderland.txt
|
||||||
|
|
2
tests/fixtures/sum/bsd_single_file.expected
vendored
2
tests/fixtures/sum/bsd_single_file.expected
vendored
|
@ -1 +1 @@
|
||||||
8109 1
|
08109 1 lorem_ipsum.txt
|
||||||
|
|
2
tests/fixtures/sum/bsd_stdin.expected
vendored
2
tests/fixtures/sum/bsd_stdin.expected
vendored
|
@ -1 +1 @@
|
||||||
8109 1
|
08109 1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue