1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-27 19:17:43 +00:00

Merge pull request #3367 from sylvestre/tty

tty: should not return 2 when --help is used
This commit is contained in:
Sylvestre Ledru 2022-04-05 08:02:28 +02:00 committed by GitHub
commit 5fbef7743b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 4 deletions

View file

@ -12,7 +12,7 @@
use clap::{crate_version, Arg, Command};
use std::ffi::CStr;
use std::io::Write;
use uucore::error::{UResult, UUsageError};
use uucore::error::UResult;
use uucore::{format_usage, InvalidEncodingHandling};
static ABOUT: &str = "Print the file name of the terminal connected to standard input.";
@ -28,9 +28,7 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
.collect_str(InvalidEncodingHandling::ConvertLossy)
.accept_any();
let matches = uu_app()
.try_get_matches_from(args)
.map_err(|e| UUsageError::new(2, format!("{}", e)))?;
let matches = uu_app().get_matches_from(args);
let silent = matches.is_present(options::SILENT);

View file

@ -64,6 +64,11 @@ fn test_wrong_argument() {
new_ucmd!().args(&["a"]).fails().code_is(2);
}
#[test]
fn test_help() {
new_ucmd!().args(&["--help"]).succeeds();
}
#[test]
// FixME: freebsd panic
#[cfg(all(unix, not(target_os = "freebsd")))]