1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-07-29 12:07:46 +00:00

Merge pull request #3047 from hbina/hbina-touch-better-msg-when-no-args

touch: Better error messages when no args is provided
This commit is contained in:
Sylvestre Ledru 2022-02-04 10:27:01 +01:00 committed by GitHub
commit 033fd62f6a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 1 deletions

View file

@ -58,7 +58,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
let files = matches.values_of_os(ARG_FILES).unwrap();
let files = matches.values_of_os(ARG_FILES).ok_or_else(|| {
USimpleError::new(
1,
r##"missing file operand
Try 'touch --help' for more information."##,
)
})?;
let (mut atime, mut mtime) =
if let Some(reference) = matches.value_of_os(options::sources::REFERENCE) {

View file

@ -530,3 +530,12 @@ fn test_touch_permission_denied_error_msg() {
&full_path
));
}
#[test]
fn test_touch_no_args() {
let mut ucmd = new_ucmd!();
ucmd.fails().stderr_only(
r##"touch: missing file operand
Try 'touch --help' for more information."##,
);
}