From 7b35749ea64ad20af7a41aa5d5796f2e75abd592 Mon Sep 17 00:00:00 2001 From: Jeffrey Finkelstein Date: Sat, 17 Sep 2022 16:04:28 -0400 Subject: [PATCH] mktemp: match GNU error message on too many args Update the usage message when too many template arguments are given on the command line to match that of GNU mktemp: mktemp: too many templates Try 'mktemp --help' for more information. This fixes the test case `too-many` in the GNU test suite file `tests/misc/mktemp.pl`. --- src/uu/mktemp/src/mktemp.rs | 12 ++++++++++-- tests/by-util/test_mktemp.rs | 6 +++++- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/uu/mktemp/src/mktemp.rs b/src/uu/mktemp/src/mktemp.rs index dfa7fd103..dac2a097b 100644 --- a/src/uu/mktemp/src/mktemp.rs +++ b/src/uu/mktemp/src/mktemp.rs @@ -10,7 +10,7 @@ use clap::{crate_version, Arg, ArgMatches, Command}; use uucore::display::{println_verbatim, Quotable}; -use uucore::error::{FromIo, UError, UResult}; +use uucore::error::{FromIo, UError, UResult, UUsageError}; use uucore::format_usage; use std::env; @@ -327,7 +327,15 @@ impl Params { pub fn uumain(args: impl uucore::Args) -> UResult<()> { let args = args.collect_lossy(); - let matches = uu_app().try_get_matches_from(&args)?; + let matches = match uu_app().try_get_matches_from(&args) { + Ok(m) => m, + Err(e) => { + if e.kind == clap::error::ErrorKind::TooManyValues && e.info[0] == "