mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
dd: truncate to specified seek length
When specifying `seek=N` and *not* specifying `conv=notrunc`, truncate the output file to `N` blocks instead of truncating it to zero before starting to write output. For example $ printf "abc" > outfile $ printf "123" | dd bs=1 skip=1 seek=1 count=1 status=noxfer of=outfile 1+0 records in 1+0 records out $ cat outfile a2 Fixes #3068.
This commit is contained in:
parent
ebf33d775e
commit
1af709f642
2 changed files with 28 additions and 7 deletions
|
@ -604,5 +604,27 @@ fn test_seek_bytes() {
|
|||
.stdout_is("\0\0\0\0\0\0\0\0abcdefghijklm\n");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_seek_do_not_overwrite() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
let mut outfile = at.make_file("outfile");
|
||||
outfile.write_all(b"abc").unwrap();
|
||||
// Skip the first byte of the input, seek past the first byte of
|
||||
// the output, and write only one byte to the output.
|
||||
ucmd.args(&[
|
||||
"bs=1",
|
||||
"skip=1",
|
||||
"seek=1",
|
||||
"count=1",
|
||||
"status=noxfer",
|
||||
"of=outfile",
|
||||
])
|
||||
.pipe_in("123")
|
||||
.succeeds()
|
||||
.stderr_is("1+0 records in\n1+0 records out\n")
|
||||
.no_stdout();
|
||||
assert_eq!(at.read("outfile"), "a2");
|
||||
}
|
||||
|
||||
// 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