mirror of
https://github.com/uutils/coreutils
synced 2024-11-16 17:58:06 +00:00
touch: Better error message when no args is given
Matches the behavior of GNU touch ```shell hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks)> touch > /dev/null touch: missing file operand Try 'touch --help' for more information. hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks) [1]> cargo run --quiet -- touch > /dev/null touch: missing file operand Try 'touch --help' for more information. hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks) [1]> cargo run --quiet -- touch 2> /dev/null hbina@akarin ~/g/uutils (hbina-realpath-absolute-symlinks) [1]> touch 2> /dev/null ``` Signed-off-by: Hanif Ariffin <hanif.ariffin.4326@gmail.com>
This commit is contained in:
parent
2d3b8db9ed
commit
ff8a83b256
1 changed files with 5 additions and 1 deletions
|
@ -58,7 +58,11 @@ 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(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) {
|
||||
|
|
Loading…
Reference in a new issue