mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-28 11:37:44 +00:00
csplit: don't panic on missing suppressed file
Avoid a panic that would occur when attempting to remove a file that didn't exist. This would happen when scanning for a regular expression match, advancing by a positive offset, and suppressing empty files. For example, before this commit, echo a | csplit -z - %a%1 would cause a panic. After this commit, the process terminates as expected: without error, without output, and without any files written. Fixes #7251.
This commit is contained in:
parent
aa27efb854
commit
18f9ca9da4
2 changed files with 16 additions and 1 deletions
|
@ -335,6 +335,16 @@ fn test_skip_to_match_offset() {
|
|||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skip_to_match_offset_suppress_empty() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
ucmd.args(&["-z", "-", "%a%1"])
|
||||
.pipe_in("a\n")
|
||||
.succeeds()
|
||||
.no_output();
|
||||
assert!(!at.file_exists("xx00"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_skip_to_match_negative_offset() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue