mirror of
https://github.com/uutils/coreutils.git
synced 2026-06-10 15:48:22 -07:00
cut: add gnu compatability to error messages
This commit is contained in:
@@ -401,8 +401,13 @@ fn cut_files(mut filenames: Vec<String>, mode: Mode) -> i32 {
|
||||
} else {
|
||||
let path = Path::new(&filename[..]);
|
||||
|
||||
if !path.exists() {
|
||||
show_error!("{}", msg_args_nonexistent_file!(filename));
|
||||
if path.is_dir() {
|
||||
show_error!("{}: Is a directory", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
if !path.metadata().is_ok() {
|
||||
show_error!("{}: No such file or directory", filename);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
@@ -139,3 +139,21 @@ fn test_zero_terminated_only_delimited() {
|
||||
.succeeds()
|
||||
.stdout_only("82\n7\0");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_directory_and_no_such_file() {
|
||||
let (at, mut ucmd) = at_and_ucmd!();
|
||||
|
||||
at.mkdir("some");
|
||||
|
||||
ucmd.arg("-b1")
|
||||
.arg("some")
|
||||
.run()
|
||||
.stderr_is("cut: error: some: Is a directory\n");
|
||||
|
||||
new_ucmd!()
|
||||
.arg("-b1")
|
||||
.arg("some")
|
||||
.run()
|
||||
.stderr_is("cut: error: some: No such file or directory\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user