mirror of
https://github.com/RGBCube/uutils-coreutils
synced 2025-07-27 19:17:43 +00:00
Merge pull request #5886 from cakebaker/cut_set_exit_code
cut: set exit code to 1 if directory is specified
This commit is contained in:
commit
e580627506
2 changed files with 10 additions and 4 deletions
|
@ -11,7 +11,7 @@ use std::fs::File;
|
||||||
use std::io::{stdin, stdout, BufReader, BufWriter, IsTerminal, Read, Write};
|
use std::io::{stdin, stdout, BufReader, BufWriter, IsTerminal, Read, Write};
|
||||||
use std::path::Path;
|
use std::path::Path;
|
||||||
use uucore::display::Quotable;
|
use uucore::display::Quotable;
|
||||||
use uucore::error::{FromIo, UResult, USimpleError};
|
use uucore::error::{set_exit_code, FromIo, UResult, USimpleError};
|
||||||
use uucore::line_ending::LineEnding;
|
use uucore::line_ending::LineEnding;
|
||||||
|
|
||||||
use self::searcher::Searcher;
|
use self::searcher::Searcher;
|
||||||
|
@ -319,6 +319,7 @@ fn cut_files(mut filenames: Vec<String>, mode: &Mode) {
|
||||||
|
|
||||||
if path.is_dir() {
|
if path.is_dir() {
|
||||||
show_error!("{}: Is a directory", filename.maybe_quote());
|
show_error!("{}: Is a directory", filename.maybe_quote());
|
||||||
|
set_exit_code(1);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -212,20 +212,25 @@ fn test_zero_terminated_only_delimited() {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn test_directory_and_no_such_file() {
|
fn test_is_a_directory() {
|
||||||
let (at, mut ucmd) = at_and_ucmd!();
|
let (at, mut ucmd) = at_and_ucmd!();
|
||||||
|
|
||||||
at.mkdir("some");
|
at.mkdir("some");
|
||||||
|
|
||||||
ucmd.arg("-b1")
|
ucmd.arg("-b1")
|
||||||
.arg("some")
|
.arg("some")
|
||||||
.run()
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
.stderr_is("cut: some: Is a directory\n");
|
.stderr_is("cut: some: Is a directory\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_no_such_file() {
|
||||||
new_ucmd!()
|
new_ucmd!()
|
||||||
.arg("-b1")
|
.arg("-b1")
|
||||||
.arg("some")
|
.arg("some")
|
||||||
.run()
|
.fails()
|
||||||
|
.code_is(1)
|
||||||
.stderr_is("cut: some: No such file or directory\n");
|
.stderr_is("cut: some: No such file or directory\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue