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
2 changed files with 16 additions and 1 deletions
+7 -1
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) {
+9
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."##,
);
}