From 8232c527a365050d91a6ee9d8931c0455d417474 Mon Sep 17 00:00:00 2001 From: Ricardo Iglesias Date: Tue, 6 Apr 2021 23:30:15 -0700 Subject: [PATCH] timeout: tests passing. Forgot to handle the case where no arguments were passed to the COMMAND. Because ARGS can be empty, we need two separate cases for handling options.values_of(options::ARGS) --- src/uu/timeout/src/timeout.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/uu/timeout/src/timeout.rs b/src/uu/timeout/src/timeout.rs index bd340a122..23e2ec842 100644 --- a/src/uu/timeout/src/timeout.rs +++ b/src/uu/timeout/src/timeout.rs @@ -79,11 +79,11 @@ impl Config { let foreground = options.is_present(options::FOREGROUND); let command: String = options.value_of(options::COMMAND).unwrap().to_string(); - let command_args: Vec = options - .values_of(options::ARGS) - .unwrap() - .map(|x| x.to_owned()) - .collect(); + + let command_args: Vec = match options.values_of(options::ARGS) { + Some(values) => values.map(|x| x.to_owned()).collect(), + None => vec![], + }; Config { foreground, @@ -137,7 +137,7 @@ pub fn uumain(args: impl uucore::Args) -> i32 { .required(true) ) .arg( - Arg::with_name(options::ARGS).required(true).multiple(true) + Arg::with_name(options::ARGS).multiple(true) ) .setting(AppSettings::TrailingVarArg);