mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-29 20:17:45 +00:00
Merge pull request #3129 from jfinkels/dd-partial-records
dd: correctly account for partial record written
This commit is contained in:
commit
85c4fb3981
2 changed files with 16 additions and 9 deletions
|
@ -334,17 +334,14 @@ where
|
|||
let mut bytes_total = 0;
|
||||
|
||||
for chunk in buf.chunks(self.obs) {
|
||||
match self.write(chunk)? {
|
||||
wlen if wlen < chunk.len() => {
|
||||
let wlen = self.write(chunk)?;
|
||||
if wlen < self.obs {
|
||||
writes_partial += 1;
|
||||
bytes_total += wlen;
|
||||
}
|
||||
wlen => {
|
||||
} else {
|
||||
writes_complete += 1;
|
||||
}
|
||||
bytes_total += wlen;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(WriteStat {
|
||||
writes_complete,
|
||||
|
|
|
@ -692,5 +692,15 @@ fn test_seek_do_not_overwrite() {
|
|||
assert_eq!(at.read("outfile"), "a2");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_partial_records_out() {
|
||||
new_ucmd!()
|
||||
.args(&["bs=2", "status=noxfer"])
|
||||
.pipe_in("abc")
|
||||
.succeeds()
|
||||
.stdout_is("abc")
|
||||
.stderr_is("1+1 records in\n1+1 records out\n");
|
||||
}
|
||||
|
||||
// conv=[ascii,ebcdic,ibm], conv=[ucase,lcase], conv=[block,unblock], conv=sync
|
||||
// TODO: Move conv tests from unit test module
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue