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:
commit
033fd62f6a
2 changed files with 16 additions and 1 deletions
|
@ -58,7 +58,13 @@ pub fn uumain(args: impl uucore::Args) -> UResult<()> {
|
||||||
|
|
||||||
let matches = uu_app().override_usage(&usage[..]).get_matches_from(args);
|
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) =
|
let (mut atime, mut mtime) =
|
||||||
if let Some(reference) = matches.value_of_os(options::sources::REFERENCE) {
|
if let Some(reference) = matches.value_of_os(options::sources::REFERENCE) {
|
||||||
|
|
|
@ -530,3 +530,12 @@ fn test_touch_permission_denied_error_msg() {
|
||||||
&full_path
|
&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."##,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue