mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 03:27:44 +00:00
tail: fix a bug in tail [ -n | -c ] +NUM <file>
Fix a bug when getting all but the first NUM lines or bytes of a file via `tail -n +NUM <file>` or `tail -c +NUM <file>`. The bug only existed when a file is given as an argument; it did not exist when the input data came from stdin.
This commit is contained in:
parent
d27d6bc32c
commit
f595edaded
2 changed files with 49 additions and 8 deletions
|
@ -3,7 +3,7 @@
|
|||
// * For the full copyright and license information, please view the LICENSE
|
||||
// * file that was distributed with this source code.
|
||||
|
||||
// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile bogusfile
|
||||
// spell-checker:ignore (ToDO) abcdefghijklmnopqrstuvwxyz efghijklmnopqrstuvwxyz vwxyz emptyfile bogusfile siette ocho nueve diez
|
||||
|
||||
extern crate tail;
|
||||
|
||||
|
@ -358,6 +358,37 @@ fn test_positive_lines() {
|
|||
.stdout_is("c\nd\ne\n");
|
||||
}
|
||||
|
||||
/// Test for reading all but the first NUM lines of a file: `tail -n +3 infile`.
|
||||
#[test]
|
||||
fn test_positive_lines_file() {
|
||||
new_ucmd!()
|
||||
.args(&["-n", "+7", "foobar.txt"])
|
||||
.succeeds()
|
||||
.stdout_is(
|
||||
"siette
|
||||
ocho
|
||||
nueve
|
||||
diez
|
||||
once
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
/// Test for reading all but the first NUM bytes of a file: `tail -c +3 infile`.
|
||||
#[test]
|
||||
fn test_positive_bytes_file() {
|
||||
new_ucmd!()
|
||||
.args(&["-c", "+42", "foobar.txt"])
|
||||
.succeeds()
|
||||
.stdout_is(
|
||||
"ho
|
||||
nueve
|
||||
diez
|
||||
once
|
||||
",
|
||||
);
|
||||
}
|
||||
|
||||
/// Test for reading all but the first NUM lines: `tail -3`.
|
||||
#[test]
|
||||
fn test_obsolete_syntax_positive_lines() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue