1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-28 11:37:44 +00:00

Merge pull request #2911 from jfinkels/dd-seek-stdout

dd: support seek=N when destination is stdout
This commit is contained in:
Sylvestre Ledru 2022-01-29 10:47:17 +01:00 committed by GitHub
commit 24744ca42b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 3 deletions

View file

@ -1,4 +1,4 @@
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat
// spell-checker:ignore fname, tname, fpath, specfile, testfile, unspec, ifile, ofile, outfile, fullblock, urand, fileio, atoe, atoibm, availible, behaviour, bmax, bremain, btotal, cflags, creat, ctable, ctty, datastructures, doesnt, etoa, fileout, fname, gnudd, iconvflags, nocache, noctty, noerror, nofollow, nolinks, nonblock, oconvflags, outfile, parseargs, rlen, rmax, rposition, rremain, rsofar, rstat, sigusr, sigval, wlen, wstat abcdefghijklm
use crate::common::util::*;
@ -592,5 +592,17 @@ fn test_conv_ebcdic_implies_block() {
.stdout_is_bytes(b"\x40\xc1\x40\xc1\x40\xc1\x40\x40");
}
/// Test for seeking forward N bytes in the output file before copying.
#[test]
fn test_seek_bytes() {
// Since the output file is stdout, seeking forward by eight bytes
// results in a prefix of eight null bytes.
new_ucmd!()
.args(&["seek=8", "oflag=seek_bytes"])
.pipe_in("abcdefghijklm\n")
.succeeds()
.stdout_is("\0\0\0\0\0\0\0\0abcdefghijklm\n");
}
// conv=[ascii,ebcdic,ibm], conv=[ucase,lcase], conv=[block,unblock], conv=sync
// TODO: Move conv tests from unit test module