mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
split: fix error msg shown if file doesn't exist
This commit is contained in:
committed by
Sylvestre Ledru
parent
cc1142cee6
commit
c619dbc99c
@@ -1635,12 +1635,8 @@ fn split(settings: &Settings) -> UResult<()> {
|
|||||||
let r_box = if settings.input == "-" {
|
let r_box = if settings.input == "-" {
|
||||||
Box::new(stdin()) as Box<dyn Read>
|
Box::new(stdin()) as Box<dyn Read>
|
||||||
} else {
|
} else {
|
||||||
let r = File::open(Path::new(&settings.input)).map_err_context(|| {
|
let r = File::open(Path::new(&settings.input))
|
||||||
format!(
|
.map_err_context(|| format!("cannot open {} for reading", settings.input.quote()))?;
|
||||||
"cannot open {} for reading: No such file or directory",
|
|
||||||
settings.input.quote()
|
|
||||||
)
|
|
||||||
})?;
|
|
||||||
Box::new(r) as Box<dyn Read>
|
Box::new(r) as Box<dyn Read>
|
||||||
};
|
};
|
||||||
let mut reader = if let Some(c) = settings.io_blksize {
|
let mut reader = if let Some(c) = settings.io_blksize {
|
||||||
|
|||||||
@@ -123,6 +123,15 @@ fn test_invalid_arg() {
|
|||||||
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
new_ucmd!().arg("--definitely-invalid").fails().code_is(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_split_non_existing_file() {
|
||||||
|
new_ucmd!()
|
||||||
|
.arg("non-existing")
|
||||||
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
|
.stderr_is("split: cannot open 'non-existing' for reading: No such file or directory\n");
|
||||||
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_split_default() {
|
fn test_split_default() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|||||||
Reference in New Issue
Block a user